1

Topic: NION Python NULL Byte for Serial Port?

I am having difficulty sending a NULL byte (0x00) out of the serial port with Python/NWare. For example, I am trying to send the string 0xF5 0x00 0x00 0x02 0x18 (port.write("\xF5\x00\x00\x02\x18") but all that comes out of the serial port is the 0xF5 byte. If I drop the 0x00 bytes ("\xF5\x02\x18") I get the whole string.

I can send each byte individually, one line of Python per byte (port.write("\xF5") etc), but then only the non-null bytes are sent out the serial port, so the string \xF5 \x00 \x00 \x02 \x18 comes out as \xF5 \x02 \x18.

I have tried various Python escape characters (“\x00" , “\00" ) as well as various manipulations with conversion functions (hex(), chr(), etc.). No matter what I do, there is no character output for the NULL byte.

I get the same results whether I am using a Windows serial port on a PC or a Linux serial port on the NioNode. I am using v1.4.4.

Any ideas?

Thanks!

Thanks!

Dave

2

Re: NION Python NULL Byte for Serial Port?

Sorry, don't have the answer; but I had the same issue trying to read in a string that contained 0x00 bytes.

So I'd second the request for ideas.

thanks

"The single biggest problem in communication is the illusion that it has taken place."
                                                                                        - George Bernard Shaw

3

Re: NION Python NULL Byte for Serial Port?

Looks like the write method is treating the NULL byte as a string termnator. I'm betting you are going to need a method that accepts a length argument in addition to the string itself.