I have to implement an RS-485 (Modbus) interface with GO on an RPI 3B using a Seeed RS-485 Shield. This means that to get data from a Modbus device, the following has to be done:
Turn an output pin high (BCM 18) to set the communication direction of the shield to transmission,
Send a bunch of bytes to the Modbus device,
Turn the output pin (BCM 18) to low to set the shied to reception,
Read in a predefined number of bytes (this is the answer of the Modbus device).
I have done the whole process (together with other processes) with RXJAVA using Pi4J (which uses the Wiringpi library) and it works fine.
But I have to port it to C or GO because of performance (speed) reasons. And I definitely prefer doing it in GO.
I have started some basic coding but I have a problem with the part that is expected to receive a predefined amount of bytes. If I suspect well, the problem is with the answer coming from the Modbus device, because it contains 0x00 bytes as well. What I need is a code snippet that reads a predefined amount of bytes (even if it contains several 0x00 bytes as well).
I have to implement an RS-485 (Modbus) interface with GO on an RPI 3B using a Seeed RS-485 Shield. This means that to get data from a Modbus device, the following has to be done:
I have done the whole process (together with other processes) with RXJAVA using Pi4J (which uses the Wiringpi library) and it works fine.
But I have to port it to C or GO because of performance (speed) reasons. And I definitely prefer doing it in GO.
I have started some basic coding but I have a problem with the part that is expected to receive a predefined amount of bytes. If I suspect well, the problem is with the answer coming from the Modbus device, because it contains 0x00 bytes as well. What I need is a code snippet that reads a predefined amount of bytes (even if it contains several 0x00 bytes as well).
Any help is welcome!