wh201906 / SerialPipe

USB Serial to UDP bridge app
MIT License
13 stars 3 forks source link

How to connect? #1

Open xxxcrow opened 1 year ago

xxxcrow commented 1 year ago

Hi, it seems like your project is exactly what I was looking for (and gave up looking for šŸ˜…)

I have a serial device, usually I connect to it with screen /dev/...

But how do I connect to this UDP? Thank you

wh201906 commented 1 year ago

I guess you need to run socat to forward the raw UDP data to the terminal first, then connect to it with screen With that said, I still don't know what you want to do. Could you please describe how you use your serial device more clearly?

wh201906 commented 1 year ago

Assuming that you need to access the serial device remotely, and you have an Android device, then you can follow these steps:

  1. Connect your serial device to the Android device via USB OTG
  2. Open SerialPipe, set the port of the UDP "server" as you wish and start it, then connect to the serial device with the required baudrate
  3. Open a terminal on your PC, run socat -dd pty,wait-slave udp4:192.168.0.11:18888. Replace the IP address 192.168.0.11 with your phone's and replace the port with the one you set in step 2. You will see something like socat[xxxx] N PTY is /dev/pts/0
  4. Open another terminal, run screen /dev/pts/0. Make sure the /dev/pts/0 matches the path at the end of step 3
xxxcrow commented 1 year ago

@wh201906 I have an nrf52840, on desktops I'm using screen to communicate But on android, with some firmwares i'm able to use "serial to telnet" app, but with some it doesn't want to work, so I hope your project can work with the latter

xxxcrow commented 1 year ago

@wh201906 oh, so you're saying this app is for a remote access to the serial

wh201906 commented 1 year ago

It can be used for accessing the USB serial device on Android too.

wh201906 commented 1 year ago

Assuming that you need to access the serial device in Termux, then you can follow these steps:

  1. Connect your serial device to the Android device via USB OTG
  2. Open SerialPipe, set the port of the UDP "server" as you wish and start it, then connect to the serial device with the required baudrate
  3. Open Termux, run screen to open a new session, then run socat -dd pty,wait-slave udp4:localhost:18888. Replace the port with the one you set in step 2. You will see something like socat[xxxx] N PTY is /dev/pts/0
  4. Press Ctrl + A then D to detach the session running socat, then run screen /dev/pts/0. Make sure the /dev/pts/0 matches the path at the end of step 3
wh201906 commented 1 year ago

Iā€™d like to promote my project there. If you don't need a full terminal experience when using the serial device, you should try SerialTest. This app supports Linux and Android. Although it doesn't support USB serial device on Android, you can use SerialPipe as a USB to UDP bridge and open the UDP connection in SerialTest directly, so you don't need socat to forward the UDP

wh201906 commented 1 year ago

But on android, with some firmwares i'm able to use "serial to telnet" app

Would you mind telling me what the "serial to telnet" app is? I think the SimpleUsbTerminal might also be helpful for you.

xxxcrow commented 1 year ago

I think the SimpleUsbTerminal might also be helpful for you.

First time I see this app, they are probably not on any of fdroid repos

Would you mind telling me what the "serial to telnet" app is?

https://github.com/ClusterM/usb-serial-telnet-server

Assuming that you need to access the serial device in Termux, then you can follow these steps:

I can try again, but after your first tutorial I already tried this, didn't work šŸ« 

wh201906 commented 1 year ago

First time I see this app, they are probably not on any of fdroid repos

There is a Google Play link in the README. You can still try it if you wish.

I can try again, but after your first tutorial I already tried this, didn't work šŸ« 

I only tested it by shorting the Tx pin and Rx pin of a CH340 and checking if my input has echo. It did work as expected.

xxxcrow commented 1 year ago

@wh201906 I don't use google play, it's easier for me to download from a git repo

I tested again, screen connects, socat responds that somebody is connected But screen has no output or input Maybe it would work with other firmwares, but it's like that with the one I tested

wh201906 commented 1 year ago

I don't use google play, it's easier for me to download from a git repo

You can try some APK downloader like this

I tested again, screen connects, socat responds that somebody is connected

You could add -x or -v option in socat to check if there is data flowing over it.

Oriebugg commented 3 months ago

Is there a way to access this from a port that doesn't need root permissions? I'm using Proot-distro and it's giving me a Permission denied error everytime I try to connect to /dev/pts/0