I have several years coding for this modules, but are some step that I can never perform.
How I can detect silence at the serial/s ports? I need to detects when the serial don’t hace more information (silence) and dispatch the serial’s buffer content.
Modbus don’t have EOF character or stream to detect, so what is the way to perform silence detect and dispatch or send the data. All this issues is done using the module running python script, in transparent mode the modem have his own internal timmer, but how I can use that if I’m running python code?
I suppose you will use Modbus over RS485 and in this case you’ll need a converter which will do the switching ways as well.
I had a project with HE910, AD485 RS232/RS485 converter, a Schneider energy meter and minimalmodbus Py library. Worked great without any problem.
That library implement other serial library that is not SER&SER2. they call it pyserial.
I will test it I don’t know if it run in a GL865 py machine.
Of course, but only a few functions are used from pyserial, you can make small replacement I (uninspirationally) called it ser_serial and import it in minimalmodbus like this:
import ser_serial as serial
Cosmin, are you using this py version ?
No Frank, as I said I used HE910 which has Py 2.7.2 with floating point, threading and other goodies. I suppose you can make minimalmodbus work with 1.5.2 with heavy cuts and work.
I don’t need to decode the MODBUS data, only fordward it the my server.
The problem with MODBUS and with all binary protocols are they don’t have EOF char.
So we must detect then the streams ends. The only way is using a timeout.
For this, at py manual from telit:
This command receives a string from the serial port TXD/RXD waiting for it until the timeout is expired. The return value will be the first string received no matter of how long the timeout is. The input parameter timeout is a Python integer, which is measured in 1/10s, and represents the max time to wait for the string from the serial port ASC0. The timeout range is (0 ÷ 32767).
The return value is a Python string which is an empty string if timeout expired without any data received, otherwise it is the string consisting in the data received.
a = SER.receive(15)
if (read != ”):
For example I send "HELOOOOOOOOOOOOO". At this stream we don’t have any inter-char delay is a complete TX.
It give me back:
So, I don’t know any way to implement this function, for me my conclusion is that SER.receive don’t work properly. I test this in GM862-GPS, GM862-PY and GL865.
I’m thinking that the internal UART control is wrong.
Not necessarily wrong, remember Python task runs with a low priority; maybe you will have better success trying byte reading operations with a generous inter-character timeout.
Re-read SER.receive explanation and you’ll understand is normal to get the returns like that.
Frank, please try to read and understand all my statements above, not only the one regarding the priority.
Hit enter to search or ESC to close
Knowledge Base & Download Zone