Jump to content

Recommended Posts

Posted

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 

Posted

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 

Posted

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 ;)

Posted

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?

Posted

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_role
modprobe g_serial
echo -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_role
rmmod g_serial
echo -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 !

Posted

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 port

ttySG0:

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 config

root@orangepione:/home/sdosa/DATA# stty -F /dev/ttyGS0
speed 9600 baud; line = 0;
-brkint -imaxbel

tty.usbmodem2411:

stty -f /dev/tty.usbmodem2411
speed 9600 baud;
lflags: -icanon -isig -iexten -echo
iflags: -icrnl -ixon -ixany -imaxbel -brkint
oflags: -opost -onlcr -oxtabs
cflags: cs8 -parenb

Any 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

Posted

@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.

Posted

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 38400
stty: /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/ttyGS0
root@orangepione:/home/cdosa# ls -l /dev/ttyGS0
crw-rw---- 1 root dialout 247, 0 Jun 30 17:23 /dev/ttyGS0

root@orangepione:/home/cdosa# stty -F /dev/ttyGS0 -a
speed 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 -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

root@orangepione:/home/cdosa# echo "xxxxxxxxxxxx hello from OPI xxxxxxxxxxxx" >/dev/ttyGS0

root@orangepione:/home/cdosa# setserial -g /dev/ttyGS0
Cannot get serial info: Invalid argument

 

 

 So thats it... no luck for me yet. /R

Posted

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.

Posted

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

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines