Using is fairly simple, you just open the serial device using the built-in
fs and run the ffi functions on the FD:


    local fd = assert(fs.open(device, mode))
    set_termio(fd, baud)

https://github.com/kubos/kubos/blob/15f8bd97c080d1f34c8b2cf93c9cfcecb7571e9a/services/communication-service/libs/transport-serial.lua#L39-L40

On Wed, Aug 22, 2018 at 11:00 AM Tim Caswell <[email protected]> wrote:

> It's not too hard with FFI.  The closest docs are this article:
> http://luvit.io/blog/pty-ffi.html
>
> At a past job, I did a lot of serial stuff with luvit.  Luckilly, it's
> open source and can be found at
> https://github.com/kubos/kubos/blob/15f8bd97c080d1f34c8b2cf93c9cfcecb7571e9a/services/communication-service/libs/termios-serial.lua
>
> On Wed, Aug 22, 2018 at 4:28 AM Bram Roelandts <[email protected]> wrote:
>
>> Hi
>>
>> I've been using Luvit for quite some time and it's a great fit for my
>> project. Sadly though, there's no serial port library available at the
>> moment. Since I really need the serial port, I was hoping you guys could
>> give me a few pointers.
>>
>> I've come across a thread from 2016 about serial support (
>> https://groups.google.com/d/msg/luvit/m_bJes9J2p0/u2hi21_4CQAJ), but I
>> was unable to run the posted gists. Someone apparently did get the serial
>> port working, but didn't open-source it. The guy said they used "a mixture
>> of Luvit, C and FFI. FFI for read and write, C for line monitoring threads
>> and Luvit (uv.poll for events on the port)", which already gives a basic
>> idea.
>>
>> I'm quite comfortable working with Luvit by now, but I lack knowledge to
>> write a library myself using libuv and FFI. How would I go about this?
>> Should I read up on libuv and FFI and try to hack something together? What
>> are some good resources to get started? I'm eager to learn, but I simply
>> wouldn't know where to start on this one.
>>
>> Thanks in advance!
>>
>> Kind regards,
>> Bram
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "luvit" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"luvit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to