Page 1 of 1

Serial ports?

Posted: Mon Dec 01, 2014 1:38 pm
by SPlice
I was wondering how much bother would it be to add some sort of support for communication through serial ports to love? I want to use love to do stuff with my machines, right now I use processing but I really like lua. I feel like this functionality would open up a lot more options and make love more useful to artists and inventors.

Any thoughts? Am I being silly? Do I just need a simple to use library? Can I write my own in lua using love as it is now??

Re: Serial ports?

Posted: Mon Dec 01, 2014 2:57 pm
by s-ol
SPlice wrote:I was wondering how much bother would it be to add some sort of support for communication through serial ports to love? I want to use love to do stuff with my machines, right now I use processing but I really like lua. I feel like this functionality would open up a lot more options and make love more useful to artists and inventors.

Any thoughts? Am I being silly? Do I just need a simple to use library? Can I write my own in lua using love as it is now??
You can import native lua libraries in love, see this thread for reference: viewtopic.php?f=5&t=2076
I am 99% sure there is a lua library for serial ports.

Edit:
or just use lua's fileio: http://stackoverflow.com/questions/2520 ... ort-in-lua

Re: Serial ports?

Posted: Wed Dec 03, 2014 9:32 pm
by soulaymenc
I made a love app that communicates with an arduino using serial port on linux, it's pretty easy, as on linux a serial port is nothing more but a file (FILE *) you just open it in both read and write mode.

Re: Serial ports?

Posted: Sat Dec 06, 2014 8:25 am
by SPlice
So I decided the best option would be to use lua's built in io stuff as I don't want to have to compile my own version of love for the project, now I need to figure out if I can get to the com ports on windows 7 as simply as people seem to be able to on linux

Edit: and it seems that would be a no... I suppose I should really be running linux but I could prob also figure a way to send the data from the serial port to localhost and use luasocket.... it would sure be nice if love had its own built in serial library

Re: Serial ports?

Posted: Sat Dec 06, 2014 8:49 am
by s-ol
SPlice wrote:So I decided the best option would be to use lua's built in io stuff as I don't want to have to compile my own version of love for the project, now I need to figure out if I can get to the com ports on windows 7 as simply as people seem to be able to on linux

Edit: and it seems that would be a no... I suppose I should really be running linux but I could prob also figure a way to send the data from the serial port to localhost and use luasocket.... it would sure be nice if love had its own built in serial library
Why a no? Windows Serial Ports are "COM" ports; you can open them like files too, their names are just "COM1", "COM2" etc.

http://lua-users.org/wiki/SerialCommunication

Re: Serial ports?

Posted: Mon Dec 08, 2014 3:56 am
by Positive07
I did something a little bit... ugly to get access to COM ports, since none of the options seemed to work for me and I had a deadline.
I coded an app in C# to gain access to the SerialPorts API in .NET framework, and made a TCP server to control it. In Lua I created a TCP client that connects to that server and with simple commands I'm able to control how the port is configured and the data that goes in and out of the port.

You can check it out in the projects page http://www.github.com/Positive07/Risem. It's rather UGLY but it worked for me