2 may
2021

Can i transmit serial data only using a data cable via Raspberry pi 0 w's USB port?[]

First i am a lost noob

I have been recently trying to find out a way weather i can send serial data (large file like image data) only through the Rpi w 0's micro USB port using ttyGS0.but when i searched online i only found ways of setting up headless through serial and other stuff which was no what i wanted. But i did follow the tutorial half way

  • I went to '/boot/config.txt' and set 'dtoverlay=dwc2' at the end of the file after leaving a line

  • I went to '/boot/cmdline.txt' and did put 'modules-load=dwc2,g_serial' after 'rootwait' leaving a space

Thinking i could just use the /dev/ttyGS0 in my serial program on the Rpi and send the data the data was being sent but on my PC when i tried to access my Rpi which was on comport 12 it said port not found and couldn't open it.But it was showing up in the device manager as 'PI USB to Serial(COM12)'

Then i wondered weather it would be possible at all to access Rpi's comport this way.

If that's the case, i want to know if there is any other way to access the Rpi's USB port only using the USB cable

Note:-

  • I don't want to use Rpi's USB as a way of loging ie. 'headless setup'.i just want to receive serial data like an arduino.
  • I don't want to use the GPIO pins(i tried) as they can only send limited characters at a time and i want to send an image file. Very quickly.
  • I don't have any serial converters at hand so i could route it to the arduino and use /dev/ttyUSB0 then read it on PC. I just only want to use the USB cable.
  • In case this info is required:-
    • my pc is a probook 6560b running windows 7

things i found while testing and stuff:-

  • I did do -lsusb command but i dint find my device on that list
  • I tried the 'ls /dev/ttyGS0' and i found '/dev/ttyGS0'
  • I checked many forums and some guys were asiking to use this command 'dmesg | grep tty'and show them the code . So i performed it i dont understand what alot in the piece of text means but if it would be helpfull i pasted it here:-
pi@aloypi:~ $ dmesg | grep tty
[    0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=1366 bcm2708_fb.fbheight=768 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:6D:50:77 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  console=tty1 root=PARTUUID=4ab8bcad-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial
[    0.001496] printk: console [tty1] enabled
[    2.543414] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    2.561791] 20215040.serial: ttyS0 at MMIO 0x20215040 (irq = 53, base_baud = 50000000) is a 16550
[    6.716694] systemd[1]: Created slice system-getty.slice.

  • i also tried this one 'dmesg | grep dwc2' out of curiosity and got this but i cant say anything judging it so ya
pi@aloypi:~ $ dmesg | grep dwc2
[    0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=1366 bcm2708_fb.fbheight=768 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:6D:50:77 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  console=tty1 root=PARTUUID=4ab8bcad-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial
[    2.379190] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    2.386185] dwc_otg: FIQ enabled
[    2.386205] dwc_otg: NAK holdoff enabled
[    2.386219] dwc_otg: FIQ split-transaction FSM enabled
[    2.386245] Module dwc_common_port init
[    2.968203]     modules-load=dwc2,g_serial
[    8.344134] dwc2 20980000.usb: supply vusb_d not found, using dummy regulator
[    8.367130] dwc2 20980000.usb: supply vusb_a not found, using dummy regulator
[    8.626751] dwc2 20980000.usb: EPs: 8, dedicated fifos, 4080 entries in SPRAM
[    8.647109] dwc2 20980000.usb: DWC OTG Controller
[    8.653810] dwc2 20980000.usb: new USB bus registered, assigned bus number 1
[    8.726672] dwc2 20980000.usb: irq 33, io mem 0x20980000
[    8.787097] usb usb1: Manufacturer: Linux 5.10.17+ dwc2_hsotg
[    9.371395] dwc2 20980000.usb: bound driver g_serial
[  194.158373] dwc2 20980000.usb: new device is high-speed
[  194.189677] dwc2 20980000.usb: new device is high-speed
[  194.225164] dwc2 20980000.usb: new address 3

If anyone can help me it would be very greatly appreciated and your help could help a lot more people starting their journey with the Raspberry as well cause many people seem just about as lost as i am about this topic.

Once again thanks Bros

COMENTARIOS

Blizzard

Ok looks like i made some progress till now I did this

  • I went to '/boot/config.txt' and set 'dtoverlay=dwc2' at the end of the file after leaving a line

  • I went to '/boot/cmdline.txt' and did put 'modules-load=dwc2,g_serial' after 'rootwait' leaving a space

  • I did this 'sudo nano /etc/rc.local' and placed 'modeprobe g_serial use_acm=0' before 'exit 0'

  • Then i performed this command 'sudo systemctl stop getty@ttyGS0.service' and then this 'sudo systemctl disable getty@ttyGS0.service' (i think disabling getty@ttyGS0.service and puting 'modeprobe g_serial use_acm=0' in the folder metioned above allowed rpi and pc to comunicate but then again i can be wrong )

  • then perfored a 'sudo reboot'

this seemed to solve my problem

but i have one more problem now whatever is sent from the rpi i can only recieve in the coolterm serial port reading software i cant seem to use read the port from processing for some reason (im using processing to later read the image file being sent) here is my current serial reading program in processing

import processing.serial.*;
Serial myPort;  // Create object from Serial class
String val;     // Data received from the serial port
void setup()
{
  myPort = new Serial(this, "COM13", 115200);
}
void draw()
{
  if ( myPort.available() > 0) 
  {  // If data is available,
    val = myPort.readStringUntil('\n');         // read it and store it in val
  } 
  if (val!=null)
  {
    println(val); //print it out in the console
  }
}

i kinda am stuck here :P

EDIT welp nevermind i solved it i finally finally got it working yaaaaaaaayyy OK now remember all who seek for the answer when using /dev/ttyGS0 it uses the CTS and RTS protocall (now idk if it can be disabled but please lemme know you guys)

  • Its like the pi asks your pc wether it is cleared to send the data and when the pc says yeah ok send the data the pi sends it so whenever your using this method please enable rts or cts this is what i used in processing to recieve the data
import processing.serial.*;
Serial myPort;
void setup()
{
  //remember to set the COM port to which your pi is set
  size(200, 200);
  myPort = new Serial(this, "COM13", 115200);
  
}
void draw()
{
  
  if ( myPort.available() > 0)
  {
    if(myPort.getCTS()==true){
      myPort.setRTS(true);
      print(myPort.read());
    }
  } 
}

i hope this is of loadsa help to you guys but if there is some correction needed please lemme know yall:D thanks

DEJA TU COMENTARIO

© 2017 website by Rubit Corporation