reamond Posted June 16, 2016 Posted June 16, 2016 Hi, I would like to establish communication between Pi One and a computer through OTG Usb to USB. My goal is to use it to create a serial communication between the PI One and the computer to be able to send quick strings from the PC to the PI. I have a program which only communicate through serial com port and I would like to feed it with data from the PI. Is it possible... to use the physical interface to communicate? Is it possible to establish serial communication between them? I would be very grateful for any extensive help. Thanks in advance! Hi again, I don't think I got closer to the solution... I don't want to use the debug port or the GPIO to create a fysical interface. What I would like to use USB<>Micro-USB cable to connect the otg port with a computer... And use the connection as a serial interface for communication. So, can anything like that work...? Thanks for your help and patience. /Regards
tkaiser Posted June 16, 2016 Posted June 16, 2016 Is it possible to establish serial communication between them? Most probably all you need is just an USB-to-UART-thingie like this http://www.ebay.com/itm/6Pin-USB-2-0-to-TTL-UART-Module-Serial-Converter-CP2102-STC-Replace-Ft232-Module-/401092508083 Connection / instructions here: http://linux-sunxi.org/Orange_Pi_One#Locating_the_UART
zador.blood.stained Posted June 16, 2016 Posted June 16, 2016 Most probably all you need is just an USB-to-UART-thingie like this http://www.ebay.com/itm/6Pin-USB-2-0-to-TTL-UART-Module-Serial-Converter-CP2102-STC-Replace-Ft232-Module-/401092508083 Most probably @reamond meant OTG serial gadget (g_serial), which may not be activated in the kernel and also require patch similar to g_ether.
reamond Posted June 16, 2016 Author Posted June 16, 2016 Hi, I would like to establish communication between Pi One and a computer through OTG Usb to USB. My goal is to use it to create a serial communication between the PI One and the computer to be able to send quick strings from the PC to the PI. I have a program which only communicate through serial com port and I would like to feed it with data from the PI. Is it possible... to use the physical interface to communicate? Is it possible to establish serial communication between them? I would be very grateful for any extensive help. Thanks in advance! Hi again, I don't think I got closer to the solution... I don't want to use the debug port or the GPIO to create a fysical interface. What I would like to use USB<>Micro-USB cable to connect the otg port with a computer... And use the connection as a serial interface for communication. So, can anything like that work...? Thanks for your help and patience. /Regards
tkaiser Posted June 18, 2016 Posted June 18, 2016 What I would like to use USB<>Micro-USB cable to connect the otg port with a computer... And use the connection as a serial interface for communication. We added that to the kernel config yesterday. You find a pre-compiled kernel here (use dpkg -i *.deb to install followed by a reboot). Then please report back (and please also read through the commit comments what at least I would expect
tkaiser Posted June 19, 2016 Posted June 19, 2016 g_serial tested working on OPI ONE. Thx for confirmation! Anything special to consider when using this variant? Or maybe you're able to post your setup and how you used One as serial gadget?
rodolfo Posted June 19, 2016 Posted June 19, 2016 OPI ONE as serial gadget Code snippets to enable/disable usb serial gadget on OPI ONE with Armbian_5.14 g_serial_start() {echo -n 0 > /sys/bus/platform/devices/sunxi_usb_udc/otg_rolemodprobe g_serialecho -n 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role}g_serial_stop() {echo -n 0 > /sys/bus/platform/devices/sunxi_usb_udc/otg_rolermmod g_serialecho -n 1 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role} On the OPI ONE side the serial port is /dev/ttyGS0 On the host side the serial port is /dev/ttyACM0 Testing the serial connection ( plug in USB-cable on host , new interface /dev/ttyACM0 is created ) ( OPI ONE ) echo "xxxxxxxxxxxx hello from OPI xxxxxxxxxxxx" >/dev/ttyGS0 ( host ) cat /dev/ttyACM0 ( OPI ONE ) cat /dev/ttyGS0 ( host ) echo "xxxxxxxxxxxx hello from host xxxxxxxxxxxx' >/dev/ttyACM0 ( OPI ONE ) <ctrl><c> to close Note on usage : Only basic functions for simple serial communication tested. A quick test setting up a login console on /dev/ttyGS0 and conneting to it with screen /dev/ttyACM0 quickly showed the limits of g_serial gadget. To use it as a USB serial console does not make sense as g_ether provides a full fledged fast ethernet connection providing reliable network commmunication. Enjoy !
reamond Posted June 28, 2016 Author Posted June 28, 2016 Thanks for your add to the thread... I would need some more guiding, because I just can not make it work (. I take it up (ttyGS0 is created, and the OTG_ROLE is 2)... connect to my Mac..,which shows a new tty.usbmodem2411 connection. I try to send a string as you did... but its not coming up with "cat" on the other side... not even on the PI ONE in an other terminal window. Is it a config problem or I am just off the right path? Some print out about the portttySG0:root@orangepione:/home/sdosa/DATA# dmesg | egrep -i 'serial|ttySG'[ 7.088856] systemd[1]: Starting system-serial\x2dgetty.slice.[ 7.105037] systemd[1]: Created slice system-serial\x2dgetty.slice.[ 7.930490] systemd[1]: Starting LSB: controls configuration of serial ports...[ 8.680042] systemd[1]: Started LSB: controls configuration of serial ports.[ 8401.713876] g_serial gadget: Gadget Serial v2.4[ 8401.713917] g_serial gadget: g_serial ready[ 8409.225911] g_serial gadget: high-speed config #2: CDC ACM config[ 9022.693175] g_serial gadget: high-speed config #2: CDC ACM configroot@orangepione:/home/sdosa/DATA# stty -F /dev/ttyGS0speed 9600 baud; line = 0;-brkint -imaxbeltty.usbmodem2411:stty -f /dev/tty.usbmodem2411speed 9600 baud;lflags: -icanon -isig -iexten -echoiflags: -icrnl -ixon -ixany -imaxbel -brkintoflags: -opost -onlcr -oxtabscflags: cs8 -parenbAny hint where the problem should be... I just installed setserial to be able to administrate the port... but setserial seem to have problem to find it.I know its not the topic of the thread... Please help me out to figure out the problem. /R
rodolfo Posted June 30, 2016 Posted June 30, 2016 @reamond Seems like the serial gadget is created ( /dev/ttyGS0 ) on OPI and does show up on the MAC side ( tty.usbmodemxxxx ). Without any further configuration OPI serial defaults to 115200 baud. For testing purposes work as root user ( sudo ) and retry the simple procedure outlined above . It is tested and works on the OPI side - you might have to google the OS-X part. Good luck.
reamond Posted June 30, 2016 Author Posted June 30, 2016 Hi, Unfortunately I back again... Its just not giving any result... no matter what I try. To eliminate the problem I just concentrated on the OPI, with two terminal windows...one in one out. But no matters what I do... nothing I can see trough the CAT command. I followed your lead on all points... but nothing. Can I somehow verify that all components are in place and arbian have no issue... dont really know, just fishing. I tried to use "setserial" (installed), but its did not even see it (it see ttyS0, but not ttyGS0).So now I am stuck... have no idea what causing the problem, that I can not even establish a "local loop" for verification.Any hint which way should I search in the darkness?I try to set the baud rate (looks like the port is on 9600), but it can not even change it!root@orangepione:/home/cdosa# stty -F /dev/ttyGS0 38400stty: /dev/ttyGS0: unable to perform all requested operations The rest shows my attempt to show what I fed in... root@orangepione:/home/cdosa# ls /dev/ttyGS*/dev/ttyGS0root@orangepione:/home/cdosa# ls -l /dev/ttyGS0crw-rw---- 1 root dialout 247, 0 Jun 30 17:23 /dev/ttyGS0root@orangepione:/home/cdosa# stty -F /dev/ttyGS0 -aspeed 9600 baud; rows 0; columns 0; line = 0;intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff-iuclc -ixany -imaxbel -iutf8opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprtechoctl echokeroot@orangepione:/home/cdosa# echo "xxxxxxxxxxxx hello from OPI xxxxxxxxxxxx" >/dev/ttyGS0root@orangepione:/home/cdosa# setserial -g /dev/ttyGS0Cannot get serial info: Invalid argument So thats it... no luck for me yet. /R
rodolfo Posted July 1, 2016 Posted July 1, 2016 Just rechecked the steps outlined in previous posts so there must be something different in your setup. Connect Armbian device ( OPI ) to Linux host and you should be able to communicate when the /dev/ttyACMx shows up on the host without any need of setting up serial parameters ( baud rate, parity, flow control etc...). On the OS-X side this would require a suitable (acm) driver for the specific interface that shows up when you plug in the USB cable. Best of luck - you're close.
reamond Posted July 24, 2016 Author Posted July 24, 2016 Ok, It worked... after many hours... the true is I dont know what is the difference now, but it works. And serial communication is up and running between the PI One and PC. Thanks /R 1
Recommended Posts