I am trying to poll data from an instrument that uses ModBus protocol via pyserial. I need to know how to prevent pyserial from sending the command in ascii.
Here is what I have done:
Using RealTerm, I connected to the instrument and sent this command and hit "Send as Numbers": 0x33 0x03 0x9D 0xA4 0x00 0x02 0xAE 0x56. Sending this line as numbers was able to poll the data correctly: 33 03 04 BE CE 5C A8 94 99; for example, "BE CE 5C A8" translates to -0.4030, which is the number that the instrument shows on its screen.
Using RealTerm and the same command, if I hit "Send as ASCII", the polled data would be incorrect: 30 F8 04 33 CC 44 A0 04 48 16 78 B0 04 85 DA, which I cannot relate to the number shown on the instrument's screen.
Going back to Python and pyserial, when I tried writing over the serial port using serial.write("0x33 0x03 0x9D 0xA4 0x00 0x02 0xAE 0x56"), I got the same data as in step 2.
Therefore, it seems to me that serial.write() sends the command as ASCII. Does anyone know how I can send this data in a similar manner to RealTerm step 1?