Re: Sending data to the serial port (Linux)? [message #37618 is a reply to message #37528] |
Wed, 07 January 2004 06:25  |
Olaf Stetzer
Messages: 39 Registered: September 2001
|
Member |
|
|
Pepijn Kenter schrieb:
> Olaf Stetzer wrote:
>
>> Hello and a nice new year!
>>
>> Is there an easy way to send data to the serial port
>> under Linux? I have some values in a spreadsheet that
>> need to be reformatted and sent to e.g. /dev/ttyS0.
>> I think of exporting the spreadsheet as csv and read it
>> into IDL, reformatting is easy and no problem but how
>> do I send the strings to the serial interface? Probably by
>> writing to another file and doing a 'cat foobar /dev/ttyS0'?
>> Is the latter possible in the timed demo mode (I need
>> to to this at home without access to our license server).
>>
>
> Can't you just open the device in IDL with the openw procedure?
> Like so:
>
> openw, lun, '/dev/ttyS0', /get_lun
> printf, lun, "test string"
> free_lun, lun
>
> Since 'everything is a file' in linux this should work.
>
>> There is probably an easy solution without using IDL
>> any hints?) but IDL is the only language I have a
>> good pragramming experience with! :-)
>>
>
> If you want the right tool for the right job, awk is probably what
> you're looking for.
Yes I solved it with awk yesterday. I still have to try if
cat foobar /dev/ttyS0 does the right thing, I will try that
this evening. Will perl be an easy alternative if this simple
solution fails?
Olaf
|
|
|