I am trying to send/recieve data through the serial port to a logging device. I send a hex stream xF8xCDx0Dx00x00x0Ex5D to the device and receive a reponse. The code i am using is basically copied from the send_rcv.py example. However i am unable to get the data received fromt the device. I have set up a test using the RealTerm serial capture program and with the settings – 19200, 8N1 and no hardware control, the send and receive work correctly when the device is connected directly to the PC. Is there something very simple that i am missing when trying to get the module to do the same? The code is as follows:
import SERimport time
def SER_receive(timeout): res = ” start = time.time() while (time.time() – start < timeout): res = res + SER.read() return res
SER.set_speed(‘19200′,’8N1′,’none’)data = ‘xF8xCDx0Dx00x00x0Ex5D’while (1 == 1): time.sleep(1) a = SER.send(data,0) b = SER_receive(10) time.sleep(1) SER.send(b) print ‘answer’,b
many thanks if you can help
If the comms with a PC are going well of course you should look for the problem related with the logger. Check baudrate, serial properties.
Is it that string or you should mean a string of bytes, ie really including 0x00 bytes? Maybe the answer has these too and the print will need to be implemented to be able to cope with them.
Hit enter to search or ESC to close
Knowledge Base & Download Zone