Newline Translation

Posted by therm82 on 2011-02-28 13:55

My Windows Tcl scripts serial port connection is recieving extra new line characters which are cluttering up the transcript of the script. What seems to be happening is that the unit I am communiating with sends CRs or CR LF newline sequences such as CR CR LF CR CR LF. Tcl is translating this sequence into four newlines. When I use TeraTerm with this unit, only two newlines are generated.

I have set fconfigure with various tranlslation options such as {lf auto}, lf, crlf and binary without any change in the recieved characters. Could perhaps Windows be translating the CR characters to newlines and ignoring the fconfigure translation option?

Any insight will be appreciated.
Thanks
therm82

jeffh
ActiveState Staff
Mon, 2011-02-28 16:47

You may have an issue whether the device driver is doing something odd, but Tcl should still do the translation as you request it. You need to not use 'auto' of 'lf' incoming, because if you have varying newlines, auto sets to the first detected one and doesn't change. 'lf' is just binary, so you should try 'crlf' incoming translation.

therm82 | Wed, 2011-03-09 05:01

Thanks for the reply jeffh

I agree that 'crlf' translation should fix the problem. I have tested 'crlf' translation and it does not have any affect. Using the HHD Serial Port monitor I have observed the CR CR LF character sequence. Terminal emulators like TeraTerm filter out the extra CRs. Note that I am also using Expect in my scripts. Could there be settings in Expect which I need to update which could be causing this issue?

Thanks,
Therm82