[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luars232: reading a line at a time
- From: Petr Štetiar <ynezz@...>
- Date: Wed, 3 Oct 2012 21:35:45 +0200
meino.cramer@gmx.de <meino.cramer@gmx.de> [2012-06-29 17:58:27]:
> Hi,
Hi,
hope it's not that late for the reply :)
> is it possible to read a whole line in one go from a rs232 port with luars232 ?
> And if yes...how can I accomplish this?
Yes, I've created a simple wrapper[1] around luars232 and I just use it like
this (untested):
rs232 = require('rs232')
p = rs232.new()
p:open({ dev='/dev/ttyUSB0', baud='BAUD_115200' })
line = p:read_until('\r')
print('line: ', line or 'nothing')
p:close()
1. https://github.com/ynezz/openwrt/blob/ts72xx-wip/package/librs232/files/rs232.lua#L84
-- ynezz