- Edited
Hello, I’m having troubles using Bela’s ‘Serial’ library and the example source for using it, links at the bottom of this discussion: [(https://forum.bela.io/d/1214-usb-serial)].
From Bela’s IDE, I choose Examples → Communication → Serial. I then Build & run. The project finishes building and is now running, waiting indefinitely for an input that I can’t manage to send from my PC.
The default serial port specified in the setup function part of render.cpp is:
gSerial.setup ("/dev/ttyUSB0", 19200);
- Does this mean that Serial::read is polling from the board’s USB host port? Or am I wrong and it’s supposed to be polling from the client port (that’s already connected to get the board & IDE running)?
The example works for me when I’m listening on the target machine, using:
gSerial.setup ("/dev/pts/0", 57600);
Then when I ssh into root@bela.local from my host PC, I will get a response upon hitting “s” or “k” keys.
But I don’t manage to send the data straight from my PC and get a sound response.
On host PC:
$ stty < /dev/ttyACM0
speed 57600 baud; line = 0;
On Bela:
root@bela:~# grep v0 /etc/motd
Bela image, v0.3.8h, 5 January 2023
Built manually by modifying the v0.3.8g image to update the Bela
root@bela:~# who am i
root pts/0 Mar 12 14:20 (192.168.7.1) UPDATE
root@bela:~# dmesg | grep tty
[ 0.000000] Kernel command line: console=ttyS0,115200n8 root=/dev/mmcblk1p2 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet
[ 0.438341] console [ttyS0] disabled
[ 0.438440] 44e09000.serial: ttyS0 at MMIO 0x44e09000 (irq = 38, base_baud = 3000000) is a 8250
[ 0.450276] console [ttyS0] enabled
root@bela:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@bela:~# ls /dev/
Long list of devices, none of which end with “USB” or “ACM”. ttyS0 through ttyS5 are there.
I tried changing the device in the gSerial.setup line to some of them but none worked. Including things i’ve seen elsewhere in the forum:
gSerial.setup ("/dev/ttyS0", 57600); // 57600 to match with /dev/ttyACM0 on host PC
gSerial.setup ("/dev/ttyGS0", 9600); // I configured 9600 on PC’s /dev/ttyACM0 in order to match, couldn’t change
I would then type in a terminal on the host PC:
$ echo "s" > /dev/ttyACM0
But there’s no reaction.
- How can I know what device I should specify in gSerial.setup (device, speed) in order to receive data from the PC?
- What would sending an ‘s’ or ‘k’ look like on the host PC - using the echo command, some other manner?
When I tried connecting the BBB’s USB host port to one of my PC’s USB host ports using a cable with two standard plugs, none of the command line outputs above changed. I successfully connected a computer mouse to this board’s USB host port so I know it’s active.
Kind regards