Reputation: 971
On Ubuntu 16.04 in VirtualBox, with a Beaglebone Black connected to a USB port, running the following code returns an error:
import serial
ser = serial.Serial()
ser.port = '/dev/sdb'
ser.baudrate = 9600
ser.open()
Error:
Could not configure port: (22, 'Invalid argument')
I acquired the BBB's path using blkid
in the terminal. The BBB is normally accessible using SSH in the virtual Machine.
What is causing the error, why can't Python open the port?
Edit
The output of blkid
is:
/dev/sr0: UUID="2017-07-17-16-26-18-00" LABEL="VBOXADDITIONS_5.1.24_117012" TYPE="iso9660"
/dev/sda1: UUID="58957263-a785-44f1-89a0-a66efd56623f" TYPE="ext4" PARTUUID="306fada4-01"
/dev/sda5: UUID="2e8ad169-1527-4336-9169-e189688038cd" TYPE="swap" PARTUUID="306fada4-05"
/dev/sdb: SEC_TYPE="msdos" LABEL="boot" UUID="0CD5-4AE7" TYPE="vfat"
/dev/sdc1: LABEL="WATTO" UUID="BAF1-8FE6" TYPE="vfat" PARTUUID="1299f9fa-01"
Where /dev/sdb
is the BBB's path and /dev/sdc1
the USB stick's path.
ls -l /dev/sd*
returns:
brw-rw---- 1 root disk 8, 0 jul 31 11:14 /dev/sda
brw-rw---- 1 root disk 8, 1 jul 31 11:14 /dev/sda1
brw-rw---- 1 root disk 8, 2 jul 31 11:14 /dev/sda2
brw-rw---- 1 root disk 8, 5 jul 31 11:14 /dev/sda5
brw-rw-rw- 1 666 disk 8, 16 jul 31 16:32 /dev/sdb
brw------- 1 root root 8, 32 jul 31 16:52 /dev/sdc
brw------- 1 root root 8, 33 jul 31 16:52 /dev/sdc1
lsblk
returns:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 12G 0 disk
├─sda1 8:1 0 10G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 2G 0 part [SWAP]
sdb 8:16 1 96M 0 disk /media/alexander/boot
sdc 8:32 1 7,5G 0 disk
└─sdc1 8:33 1 7,5G 0 part /media/alexander/WATTO
sr0 11:0 1 56,8M 0 rom /media/alexander/VBOXADDITIONS_5.1.24_1170123
Upvotes: 2
Views: 5041
Reputation: 287
The Beaglebone seems to only show its filesystem via USB connection: /dev/sdb If you want to connect to it via Serial connection, you need a USB to TTY converter. (for example a PL2303HX, 2$-10$). Also you could follow this tutorial to connect the pc to your serial port.
http://www.dummies.com/computers/beaglebone/how-to-connect-the-beaglebone-black-via-serial-over-usb/
Upvotes: 0
Reputation: 6130
You probably have the wrong device name: read the link at the end in this case, VirtualBox may well misunderstand the host USB serial devices, and hence have assigned the wrong device (/dev) name.
"/dev/sdb" is probably a block device such as a hard drive.
$ ls -l /dev/sd*
brw-rw---- 1 root disk 8, 0 Jul 31 13:59 /dev/sda
brw-rw---- 1 root disk 8, 1 Jul 31 13:59 /dev/sda1
brw-rw---- 1 root disk 8, 2 Jul 31 13:59 /dev/sda2
brw-rw---- 1 root disk 8, 5 Jul 31 13:59 /dev/sda5
^
Note 'b' for block device
The serial ports will be such as "/dev/ttyUSB0"
$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Jul 31 14:34 /dev/ttyUSB0
^
Note 'c' for character device
Serial ports often have group set to 'dialout' - but this is just for information, this gets set as part of recognition that it is a serial port.
You may also wish to read this item on using host serial USB devices under VirtualBox: https://techtooltip.wordpress.com/2008/09/12/using-host-serial-port-from-guest-in-virtual-box/
Upvotes: 2