Hey everyone. Haven't written anything for a while. I got some kind of weird question.
I started programming microcontrollers. Currently working with ARM Cortex M3 (STM32L152RC). I learned to connect microcontroller to computer using COM port (DE-9) and to transfer data to and from microcontoroller using UART and RS-232.
I wonder if anyone can advise me if there is a way to do some stuff with COM ports inside Love2D. Imagine Love2D game which can be controlled with selfmade old school joystick. It would be awesome.
Thanks for any help and sorry for my English.
--- UPDATE ---
So this is what I've got: https://youtu.be/W2v4NcP3IJE
Using COM ports
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Using COM ports
Last edited by IndieKid on Tue Mar 28, 2017 12:41 pm, edited 2 times in total.
Re: Using COM ports
Just make it a USB joystick. Or write an OS driver that recognizes it as joystick. COM ports nowdays are only kept around for legacy hardware. Modern units use Ethernet and USB.
Having that said, I think I saw somewhere a COM library for Lua.
Having that said, I think I saw somewhere a COM library for Lua.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Using COM ports
I imagine raidho's answer is useless, since you are trying to do this as a hobby and because of fun and the sake of learning, I want to point you out in the direction of connecting a microcontroller through COM ports, being RS-232 or a USB simulating such port, regardless of there being a better option (USB, Ethernet).
My answer is to compile a library. The library I have used is called librs232, and I have experience compiling it under Windows, if you need more information please tell me, I can help you compile this library.
Can you tell us what OS you are using? Linux and MacOS X have file access to COM ports so it's much easier over there, there is a person that has done something simpler for this OSes instead of compiling a library.
librs232 is crossplatform so I still recommend it.
My answer is to compile a library. The library I have used is called librs232, and I have experience compiling it under Windows, if you need more information please tell me, I can help you compile this library.
Can you tell us what OS you are using? Linux and MacOS X have file access to COM ports so it's much easier over there, there is a person that has done something simpler for this OSes instead of compiling a library.
librs232 is crossplatform so I still recommend it.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Using COM ports
My fault, forgot to say that I use USB to DE-9 cable, so this could be connected to any computer. Thanks for quick answer.raidho36 wrote:Just make it a USB joystick. Or write an OS driver that recognizes it as joystick. COM ports nowdays are only kept around for legacy hardware. Modern units use Ethernet and USB.
Having that said, I think I saw somewhere a COM library for Lua.
Thanks a lot for your help. I'll take a look at this library today.Positive07 wrote:I imagine raidho's answer is useless, since you are trying to do this as a hobby and because of fun and the sake of learning, I want to point you out in the direction of connecting a microcontroller through COM ports, being RS-232 or a USB simulating such port, regardless of there being a better option (USB, Ethernet).
My answer is to compile a library. The library I have used is called librs232, and I have experience compiling it under Windows, if you need more information please tell me, I can help you compile this library.
I have Keil IDE for microcontrollers, so I use Windows for that (using terminals for COM ports). But I have a triple-boot PC with Windows, macOS and Linux, and I'm definetly looking forward on doing a game with COM support for every OS.Positive07 wrote:Can you tell us what OS you are using? Linux and MacOS X have file access to COM ports so it's much easier over there, there is a person that has done something simpler for this OSes instead of compiling a library.
librs232 is crossplatform so I still recommend it.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Using COM ports
There probably doesn't exist much people that use a custom device for games, have the same development board as you and will be able to install the code you made for such device in theirs, this segment is probably infimal or non existant... So if you know this and are fine with it then... Sure go for it!IndieKid wrote:I'm definetly looking forward on doing a game with COM support for every OS.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Using COM ports
No I meant make it have USB interface instead of rs232 interface. As a bonus, it'll work on any PC and with any app. I assume it's over Arduino, it should have USB interface onboard already, and even if not there should be plenty of USB shields.
I have a DIY device ID my own hooked up to my PC, and I made it communicate with PC over USB. It's not a HID device so I have to use libusb on PC side for communication, but it beats messing with COM ports.
I have a DIY device ID my own hooked up to my PC, and I made it communicate with PC over USB. It's not a HID device so I have to use libusb on PC side for communication, but it beats messing with COM ports.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Using COM ports
He means a USB interface, that internally simulates being a COM port. It's not actually RS-232 but they call it that because that was the original protocol for COM ports.
I wouldn't recommend using libusb for such a simple task... yes I know it's better, more customizable, and you can make it into HID, but for simple serial communication COM ports should do, and are an easy way to do the communication, using a USB cable without any bigger complication.
I wouldn't recommend using libusb for such a simple task... yes I know it's better, more customizable, and you can make it into HID, but for simple serial communication COM ports should do, and are an easy way to do the communication, using a USB cable without any bigger complication.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Using COM ports
I'm trying to do this with STM32. Started with Arduino, by the way.
I am pretty sure that RS-232 is being used in here, because the program loaded to microcontroller works with RS-232. That cable requires driver that simulates a COM port, but on the other end of cable there is a DE-9 that uses RS-232. In other words you just replace one USB port with DE-9 which is a pure COM port.Positive07 wrote: ↑Thu Feb 09, 2017 10:41 pm He means a USB interface, that internally simulates being a COM port. It's not actually RS-232 but they call it that because that was the original protocol for COM ports.
I am using USB port only because I don't have any COM ports. So this should work on any PC that have COM port.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Using COM ports
Yes, the cable is the standard part, Arduino has an other integrated circuit that does a similar conversion from UART to USB, that kinda thing is pretty common in nowadays microcontroller boards. And their drivers are also easy to find, I have used PIC 18F2550 and 18F4550 simulating COM ports directly from their USB interface couse their memory and Flash limitation don't allow for other complex USB stacks, I also have 3V3 UART to USB cable that I commonly use to interact with the BeagleBone Black serial interface for some complex debugging... All this stuff uses drivers that are commonly available and simple COM interfaces that anyone can access so it's pretty easy to communicate with them, no need to know custom protocols or configurations.
I'll respond to your PM shortly, I'm pretty sure I have 32bit dll version of the library somewhere on my Dropbox, and should work fine with LÖVE for 32 bits for Windows.
I'll respond to your PM shortly, I'm pretty sure I have 32bit dll version of the library somewhere on my Dropbox, and should work fine with LÖVE for 32 bits for Windows.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
- BruceTheGoose
- Citizen
- Posts: 76
- Joined: Sat Sep 20, 2014 2:54 pm
Who is online
Users browsing this forum: Bing [Bot] and 10 guests