Serial ports?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
SPlice
Prole
Posts: 48
Joined: Thu Jul 28, 2011 8:53 am

Serial ports?

Post 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??
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Serial ports?

Post 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

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
soulaymenc
Prole
Posts: 36
Joined: Thu Jul 11, 2013 2:03 pm
Contact:

Re: Serial ports?

Post 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.
This world is so strange.
SPlice
Prole
Posts: 48
Joined: Thu Jul 28, 2011 8:53 am

Re: Serial ports?

Post 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
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Serial ports?

Post 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

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Serial ports?

Post 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
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests