Right, so for a gamejam next week my team is planning to use some external hardware hooked into a löve application to display the scoreboard.
This means I need to communicate with an Arduino server over a USB connection.
I figured that this would require using luaSocket, but can anyone give me a few pointers? I don't have the Arduino at home so I can't actually play around with it but I'd rather not go into the jam entirely unprepared. How can I use luaSocket to connect to the Arduino and read its data? Just setting up the socket and reading bytes from it should pretty much be enough, I can probably handle the rest myself when the jam starts (I'm not sure what they'll be sending anyway).
Is it as easy as opening a UDP connection to a specific port? And how would I find the right port? Or is there more to it?
Connecting to a usb port?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Connecting to a usb port?
LuaSocket is for networking, not for serial data transfer.
You'd have to write device driver from scratch. See AVR (or whatever chip you got there) programming guides.
You'd have to write device driver from scratch. See AVR (or whatever chip you got there) programming guides.
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Connecting to a usb port?
Can löve actually do that, aren't we restricted to löve's directories ?
Re: Connecting to a usb port?
A device driver for pulling raw data from a USB port? Seriously?
That'd make things a bit more complicated.
That'd make things a bit more complicated.
Re: Connecting to a usb port?
Well what did you expected? Your PC to have magically standardized USB serial data transfer driver 100% compatible to your setup out of zillions available, and have your firmware magically match requested parameters?
Yes, you'd have to write the driver for the PC. And, the firmware for the device. Easiest way of course is to use serial port (COM), USB is vastly more complicated but still quite doable, it's just USB baudrate is a lot higher, while only 2 data channel are actually available. USB 3.0 uses more pins, which adds two simplex extra channels for both input and output, with effectively 4 channels in each direction. It's kinda complicated, unless you REALLY need the USB, you better off with COM.
So what do you do, basically: create a firmware that receives some input data and does something. Make sure to work out all the bugs, since bugs in hardware are much less pleasant thing than bugs in some PC app. You'd have to learn C in great depth as a bare minimum, preferably assembly language, in as much depth. Otherwise your chip will run like shit and will yield such a behavior that "undefined" doesn't even start to describe it.
Then create a software PC backend that would send some data via COM/USB/whatever, and expect the device to do something. You can even use LÖVE for the backend, if you can hook up USB/COM handling library.
Yes, you'd have to write the driver for the PC. And, the firmware for the device. Easiest way of course is to use serial port (COM), USB is vastly more complicated but still quite doable, it's just USB baudrate is a lot higher, while only 2 data channel are actually available. USB 3.0 uses more pins, which adds two simplex extra channels for both input and output, with effectively 4 channels in each direction. It's kinda complicated, unless you REALLY need the USB, you better off with COM.
So what do you do, basically: create a firmware that receives some input data and does something. Make sure to work out all the bugs, since bugs in hardware are much less pleasant thing than bugs in some PC app. You'd have to learn C in great depth as a bare minimum, preferably assembly language, in as much depth. Otherwise your chip will run like shit and will yield such a behavior that "undefined" doesn't even start to describe it.
Then create a software PC backend that would send some data via COM/USB/whatever, and expect the device to do something. You can even use LÖVE for the backend, if you can hook up USB/COM handling library.
Re: Connecting to a usb port?
Well, I expected the lowest level implementation to be available... you know, connect to the port and read raw binary data from it. But if even that isn't there, I guess we're going for an alternative solution.Well what did you expected?
Re: Connecting to a usb port?
Reading and sending data to the USB/COM port is one thing. Reading and sending data from within the chip is the whole different story.
Re: Connecting to a usb port?
I'm not concerned about reading and sending data from within the chip. That's on the guy building the Arduino, and that part is already working. I just need to be able to read and send raw binary data over the USB/COM port. I'll handle the formatting myself, it's all really straight-forward string-based commands.
Maybe I worded it poorly... the Arduino chip has a USB plug, and it's already configured to read and send data over its serial port. I just need to be able to read/write to the USB port on the desktop's side so that my löve script can pick up the messages that the Arduino is sending out.
Maybe I worded it poorly... the Arduino chip has a USB plug, and it's already configured to read and send data over its serial port. I just need to be able to read/write to the USB port on the desktop's side so that my löve script can pick up the messages that the Arduino is sending out.
Re: Connecting to a usb port?
Then you need some .dll/.so to connect to the USB port bypassing the OS, I dunno however you say it right but you get the idea.
Also, arduino is for 143m n00bz.
Also, arduino is for 143m n00bz.
Re: Connecting to a usb port?
If the device automatically sets itself up as a client, maybe you could use libusb and Lua bindings for it.
Shallow indentations.
Who is online
Users browsing this forum: No registered users and 211 guests