pySerial and GNU Radio

Hi there Gurus of Software Defined Radio Heaven,

I have been trying to get pySerial and GNU Radio to work together but
only
with limited success. The goal is to read data from a serial connection,
say ‘/dev/ttyUSB0’, and use it to calculate the bit error rate.

I’m using pySerial in GNU Radio the following way,

[…]
self.ser = serial.Serial(’/dev/ttyUSB0’)
self.src = gr_file_descriptor_source(gr.sizeof_char,
self.ser.fileno(),
False)
[…]

If I put a self.ser.readline() in there somewhere (before calling Run())
the next line is read correctly from the serial connection.

When I connect a file_descriptor_source with both a file_sink and a
scope_sink the result is that the file contains the correct data, no
problem, but the scope_sink just never gets updated. No errors, no
nothing. When I change the repeat parameter to true, I get a ‘lseek’
Invalid seek error.

Any ideas on how to get it working?

  • Martin

I remember needing to call os.dup() or os.dup2() on the serial device’s
file descriptor, and passing that new file descriptor to the file
source. Hope that helps! -Josh

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs