Menu

#148 PySerial deleting characters

v2.6
closed-works-for-me
None
5
2013-10-17
2013-04-22
leslie
No

I am trying to control a SRS DG535 pulse generator.

I am using the the following code:

import sys
import serial

ser= serial.Serial(4,9600, timeout =1)

# To set a value for B
ser.write("D T,3,,'1', 2,.,5,e,-,6 \r\n")

The issue is that I need either the commas or spaces because every other character is being deleted or not getting to the instrument.
For example the ideal command (which follows the API of the instrument):
ser.write("DT3,'1',2.5e-6 \r\n") [this should set a pulse at 2.5e-6 s}]

Is received by the instrument:
ser.write("D31 25-6 \r\n")

basically every other command is deleted and a "bad command" is sent. I am not sure why every other character of the ser.write() is being deleted.

Please help

Discussion

  • Chris Liechti

    Chris Liechti - 2013-05-31

    Maybe the instrument is not ready to receive the next character? Reasons could be:

    • Instrument is slow and requires hardware or software flow control (not enabled in the example shown)

    • number of data bits or stop bits is wrong (though i'd expect that the instrument would receive some garbage in this case and would not understand any command at all)

    i've not yet seen other cases where every other outgoing character was not sent. using a serial port monitor (SW or HW) and watching what is sent by the PC may give some insight.

     
  • Chris Liechti

    Chris Liechti - 2013-05-31
    • status: open --> pending-works-for-me
    • assigned_to: Chris Liechti
    • Group: --> v1.0 (example)
     
  • Chris Liechti

    Chris Liechti - 2013-10-17
    • status: pending-works-for-me --> closed-works-for-me
    • Group: v1.0 (example) --> v2.6
     

Log in to post a comment.

MongoDB Logo MongoDB