Addresses in Modbus with C# - c#

I'm trying to communicate with a microcontroller CL3-E from Nanotec using the Modbus module with the RS232 connection. The program I've been able to develop lets me send messages to the microcontroller and receive messages from it.
Doing this and giving some tries to the program, I've seen that I constantly receive the same error with the same Exception Code (2). Searching in the Internet, I've seen it has something to do with the addresses and the mapping of them, but I'm not being able to see it. It is my first time programming a communication between devices, so, if apart of solving my question, you know some bibliography I could check, I would appreciate it!!!
The register number I'm trying to access is the 0x6060, and the function number is 0x10.

Related

Is there a way to send data over computers other than UDP and Bluetooth?

I want to make a simple desktop app that receives data from my phone and does certain stuff accordingly. I don't need to send any more than 1 byte. I tried UDP but it requires firewall bypassing which is a spooky popup to click on. I also tried Bluetooth but I couldn't get it to work because most of the documentation is about BLE not Bluetooth Classic. Is there any other way I can communicate with another device from a short distance even if I'm just limited to sending 1 byte? I would like topics to research but code samples are also welcome, preferably in C#.

Create virtual hardware that listens & returns commands back to C# Application

I'm looking into developing software that would be able to listen for commands sent across the COM1 serial port, interpret them and send back unique data based off of that command.
ex) if the listener reads a command sent as 0x05, it would send back 0x10.
We currently have software in C# that sends commands across COM1 to our hardware products, but during development we are not guaranteed to always have hardware available to test on and ensure the GUI controls are functioning properly. This listener would help alleviate that issue. My coworker has been refining a python script that utilizes the Pyserial package which I plan on using to handle command protocol.
So ultimately, I am expecting my C# application to have COM1 open and sending commands while the listener program reads any data sent, interprets it and sends back the correct response. Is this the correct way of going about this?
com0com creates virtual com ports on the computer so you can run both programs on the same computer without multiple com ports and loopback cables. This could be handy when doing this kind of things.
Is this the correct way? It sounds to me like it would be easier to add a emulate mode to the C# software when it returns it's own answers without making a complex thing with serial ports and another piece of software that needs maintaining.

AT Command for receiving automatic SMS notification

I have 2 gprs/gsm modems with me at the moment one of them is huawei and the other is a prolink modem. I have no problem sending or receiving SMSes via AT Commands. However I am trying to receive automatic notification using this command AT+CNMI and I am not able to get it to work but when I try this command the modem replies with ok with no errors.
Procedures that I have performed so far
Tried numerous combination for the AT+CNMI commands 2,1,0,0,0, 2,2,0,0,0 and etc but to no avail
I have set the preferred message storage to sim card and I am able to receive message and extract it as well using various AT commands.
I tried in hyperterminal as well as using C sharp but to no avail. The built software that comes with the modem are able to receive the notification. Can someone guide me on this.
Many of these types of devices use different commands. Some use proprietary commands. Since it works fine with the included software, I would recommend figuring out how that works.
The easiest way to do this is to fire up some free serial port monitoring software. Once you get it set up, start up the software the device came with and see what commands it sends. Then, you can use those same commands yourself.
I managed to figure out the problem already :) . Basically the modem that i used makes use of several different ports and the new message notification will be received by another port. Problem solved.

Do I want to use Remoting or just a Socket connection

I'm writing code for a project that was initially written in VB6 and my partner and I are trying to slowly migrate it to .NET. In the mean time I need some feedback on how I should go about doing the following:
My users can run several instances the same program to help split several specific Messages sent to a server; a server that will IP Ban you if you send to many messages at one time. What I want to do is share these messages sent between the programs so that we can build a distributed messaging system to prevent an IP Ban - these programs are running on the same machine at the present. I'm trying to get my feet wet, so I've done several (no joke...) days worth of research and I came to the conclusion that I could write a DLL in C# .NET, incorporate the needed Interop to support COM, and have that DLL store commonly used Functions, Arrays, Etc. The function would also raise events on the VB6 program to send its messages which then the client program would send to the server its connected to.
My partner says I'm going about this the wrong way and that I should to create a Sever application that loads when the first stances of my program starts and distribute messages between my clients via Socket. This process seems like a lot of work.
I'm finding it all the more difficult because samples I've found on MSDN won't compile. If you know of a great example I'd really appreciate you posting it.
Don't use Remoting for new development. It has been deprecated in favor of WCF.
Use WCF instead. You can host a WCF service in any application, and it can communicate quite quickly and efficiently using binary over TCP/IP.

How to send data to another computer with C# like hyperterminal does through modem

I need to create a program that lets me send a string of data or a file through modem, like hyper-terminal does. Im trying to create a program that lets me send electronic billing data to Medicare, and since Medicare only accepts e-bills through modem, only hyper-terminal or another program called PC ACE Pro32 can be used.
I want to create my own program, since hyper-terminal is not user friendly, and the other program has too many things for just sending data.
I've never before had experience creating code for data communication. Can somebody please help me?
There are a lot of pieces here, so let me break this down into sub questions for you:
1) How do I do serial communication in C#?
There are plenty of examples on the internet. A quick search turns up this one and this one, both of which seem to be ok. There are also lots of questions here on SO about C# serial communication.
2) How do I control a modem?
Modems are operated by some version of the AT command set. If you're familiar with manually operating a modem in HyperTerminal, you're essentially doing the same thing, but in code. For example, to test if your modem is paying attention (i.e., that your serial line is talking to the modem properly), you send AT, and see if the modem replies with OK. To dial, you send the modem ATDT <phone number>. Once a modem establishes carrier, then whatever you send down the serial port is transmitted to the remote computer.
3) How do I communicate with medicare's electronic claims system?
This one is up to you! I'd be surprised if they didn't have a web-based claims service though. I would expect that would be a lot easier than doing it over a modem.
Define a receiving connection in remote computer.
Set up a connection to remote computer just like any dial-up connection.
Use socket programming (TCP) to send/receive data to/from remote computer. Note that you must create a client/server application that resides in both remote and local computer.
Seth, your answer is actually very promising. Ill be taking a look at those suggested links right away.
(yes, medicare should be moving to ethernet, but reality is that they are stuck in dialup because they say that "it's more secure than ethernet", when in reality it's not.

Categories

Resources