0
votes

I have been trying to get pySerial to send commands to a device (Weight scale, and mass flow controller) both use ASCII format, and both do not respond to comands sent. However I can easely control both with use of Terminal. I have create a virtual comport to see whats being sent to my devices from pySerial but it sends correct data. (T\r\n is sent as T 13 10, same as what Terminal sends ) so I am at a loss. It seems as though pySerial sends out the right data to my device but for what ever reason is not properly accepted, strangely I can easely read data from the device using pySerial. Its just that the writing section fails, any suggestions on how to trouble shoot or fix this issue?

The code is myserialport.write('T\r\n')

I have tried to use flush() and flushOutput() but neither did the trick, I also tried to send the commands conseticutavely in a loop, but it did not work eather. its not a hardware issue, since I can control equipment useing Terminal program and only does not work with pySerial...

1
You checked flowcontrol settings? Baudrate and parity must be correct if you can receive correctly.Gjordis
I can recieve corectly. The Terminal settings are set to no flowcontrol. Which pyserial disables on default. but I will check that.user1957292
Try putting a delay between sending and recieving, say 2 sec.f p
I am just trying to send a command to the device, T\r\n tares the scale. I have tried seting xonxoff, but no luck. as well used time.sleep() to set a delay between writes, with no luck, in both cases the scale does not tare. yet it will tare if I send same commadn with terminal.user1957292
Put time between the chars in the write.f p

1 Answers

0
votes
for i in data:
    PID.write(i)
    time.sleep(1)

You type slower in a terminal than a serial port write and it needs time to read each char. The scale (or whatever) is usually very slow compared to a PC.