lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 11/05/2017 02:21 PM, Enrico Colombini wrote:
> On 05-Nov-17 15:10, dyngeccetor8 wrote:
>> I had similar problem when mated Lua with Arduino. Bare opening device as file
>> works well:
>>
>>    file_name = '/dev/ttyUSB0'
>>
>>    comm_read = assert(io.open(file_name, 'r'))
>>    comm_read:setvbuf('no')
>>    comm_read:flush()
>>
>>    comm_write = assert(io.open(file_name, 'w'))
>>    comm_write:setvbuf('no')
>>    comm_write:flush()
>>
>>
>> Or you need some specific features?
> 
> Interesting. But how do you set serial speed and port features (byte format, no
> echo, no hardware handshake, raw data, etc.)?

I guess this is done somewhere in OS layer. I was amazed too that opening
'/dev/ttyUSB<N>' works. Also did search with Lua maillist, there is mention for
this way.

(My case was linking Arduino module (which uses serial protocol over USB with
preset 9600 baud speed) with Love graphic frontend. So given snippet is from
real code.)

-- Martin