WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: RaspberryPi as RS232 multiplexer using piCore  (Read 6979 times)

Offline stoker

  • Newbie
  • *
  • Posts: 15
RaspberryPi as RS232 multiplexer using piCore
« on: June 02, 2017, 08:22:33 AM »
Hi

I've been using piCore for sometime now in the form of piCorePlayer and it occurred to me that a rPi with piCore might be suitable for a project I'm starting to think about.

I'd like make a rs232 multiplexer. I'd need 3 rs232 ports (2 input only and 1 bi-directional). I'd also need the rPI to act as a wifi access point so that users can connect to the rPi with their smart phones to receive the rs232 data repackaged as UDP or Tcp/IP packets.

Is it possible to use 3 USB-RS232 adapters with rPI/piCore? Or possibly 2 adapters and rPi's built in rs232 interface?

Is it possible to use a USB WiFi dongle as a wireless access point, for multiple connected devices? there will be no need for the system to be connected to the internet (or any other network once it's been configured).

I'm intending (if possible) to write the software to control this in Python.

If anyone has any suggestions as to the viability of the rPI/piCore for this application or any answers to the above questions I'd be very grateful.

Thanks in advance
--Ian

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #1 on: June 02, 2017, 09:01:42 AM »
I can't say anything about RS-232 but I just made my RPi3 a WiFi access point using busybox dhcpd and hostapd.
Download a copy and keep it handy: Core book ;)

Offline stoker

  • Newbie
  • *
  • Posts: 15
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #2 on: June 05, 2017, 04:11:40 AM »
Thanks Misalf, I'll take a look at dhcpd and hostapad

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #3 on: June 05, 2017, 05:30:04 AM »
I might be off here as I have no idea how a RS-232 multiplexer is used, however, if you run out of serial devices (i.e.  /dev/ttyS0  to  /dev/ttyS3  is not enough) you can increase their number via boot code:
Code: [Select]
8250.nr_uarts=8
Download a copy and keep it handy: Core book ;)

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #4 on: June 05, 2017, 08:07:01 AM »
Your best bet might be to use USB to serial converters and a USB hub, or one of the multiport adapters available. I've used USB to RS-232 and RS-485 converters with Linux no problems; they've always worked right out of the box on Slackware. You'll just need to find the extension that has the modules you need for the converters you use.

Offline stoker

  • Newbie
  • *
  • Posts: 15
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #5 on: June 05, 2017, 01:00:48 PM »
Thanks again for the replies, it looks like it could work then. I'll do some further research.

Just as background, this would be used on a sailing yacht, we have instrumentation (wind/depth/speed/compass) which provides an RS232 stream of data, we also have a GPS and AIS which also provide RS232 streams of data. What I intend to do is receive all this data on a rPi and then make it available as Tcp/ip so that various hand help devices and the yachts on board laptop can connect using WiFi. These computing devices are used to help with navigation and tactical decision making when racing.

Cheers
--Ian   

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #6 on: June 05, 2017, 02:08:04 PM »
I just noticed I said
  busybox dhcpd 
where I should have said
  busybox udhcpd 
Download a copy and keep it handy: Core book ;)

Offline M-H

  • Newbie
  • *
  • Posts: 24
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #7 on: June 08, 2017, 06:33:04 PM »
Hi Stoker.

Nice idea to redistribute that data over WIFI.
You could put all data on a web page and serve that from the pi.
At the same time it could also be displayed on a monitor connected to the pi.
And of course log the info to some USB stick for later review, like a plane its back box.
But for safety/backup be sure you can access the info if the pi is not functional.
And do not show info that is no longer current.

Serial to USB devices should give you up to 3 inputs on a pi B+ and newer,
I wouldn't use the pi3 onboard wifi, as its driver support isn't topnotch jet.
So add a wifi dongle to the 4th port.
With signal level converters you should be able to use the onboard uart too, if you need a 4th.

Greetz M-H

Offline jefferee

  • Newbie
  • *
  • Posts: 31
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #8 on: June 27, 2017, 12:48:59 PM »
+1 on using a multiport adapter. Anything with an FTDI chipset should work out of the box.

Occasionally I see a line in dmesg like
Code: [Select]
ftdi_sio ttyUSB13: usb_serial_generic_read_bulk_callback - urb stopped: -32which will stop comms on that port until my software detects the inactivity, closes the port, and reopens. Not a big deal, probably a once-a-week occurrence, but your code will need to detect when fresh data stops and handle accordingly.
« Last Edit: June 27, 2017, 12:52:37 PM by jefferee »

Offline stoker

  • Newbie
  • *
  • Posts: 15
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #9 on: August 08, 2017, 04:58:41 AM »
I just noticed I said
  busybox dhcpd 
where I should have said
  busybox udhcpd

Thanks for the clarification.

I've just come back to this after a while doing other stuff. I now have my rPI3 up and running using piCore 9.0.3. Unfortunately I'm having trouble finding much info about how to use busybox udhcpd, maybe I'm just not good at google! I have found this tutorial about turning a rPi into a wireless access point: http://elinux.org/RPI-Wireless-Hotspot

The tutorial is aimed at Rasbian not PiCore but I was hoping it'd be similar with piCore. The first issue I'm having is the tutorial references 2 config files: /etc/udhcpd.conf and /etc/default/udhcpd neither of which exist in piCore. Should I just create them in the location specified? I've tried using find and I'm pretty sure they don't exist else where in the file system.

Thanks for any help on this.
Cheers
Ian

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14849

Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #11 on: June 14, 2018, 05:02:06 AM »
Yes I know it's an old thread...
@Stoker: did you ever succeed using a Pi with TC to create a NMEA muxer+wifi?

I'm about to try and do the same thing with a Pi Zero W combined with a micro-USB-OTG to 4 port HUB with USB to RS422 adapters.
Completely new to TC though, so been looking for previous experiences.

Offline stoker

  • Newbie
  • *
  • Posts: 15
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #12 on: August 09, 2018, 10:11:23 AM »
Yes I know it's an old thread...
@Stoker: did you ever succeed using a Pi with TC to create a NMEA muxer+wifi?

I'm about to try and do the same thing with a Pi Zero W combined with a micro-USB-OTG to 4 port HUB with USB to RS422 adapters.
Completely new to TC though, so been looking for previous experiences.

Yes, I did succeed! It's been in use on the yacht (on and off) for a while now. 3 RS232 sources of NMEA data (plus one return path) all available to anything that tries to connect: laptop, phones etc.

I used a rPi3, 4 way usb to serial adapter and wrote the software in Python. I also used the excellent info posted by Chicany in this post: http://forum.tinycorelinux.net/index.php/topic,21569.0.html to set up the rPi as an access point.

If you have any specific questions, ask away!

--Ian


Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #13 on: October 21, 2018, 05:49:04 AM »
Thanks for coming back to me!

I managed to get my setup (zeroW, OTG 4port usb hub with RS422 converters) working. 6 weeks of flawless sea trials done. Very happy with it. I didn't write any software but simply compiled kplex on picore.

Offline stoker

  • Newbie
  • *
  • Posts: 15
Re: RaspberryPi as RS232 multiplexer using piCore
« Reply #14 on: January 08, 2019, 05:54:33 AM »
I didn't write any software but simply compiled kplex on picore.

That's interesting, did you need to do/install anything on piCore in order to compile kplex? Looking at the documentation for kplex it seems it does everything that I'm doing in my Python code and that it may be a little more stable!

Cheers
--Ian