title: Pyserial: Could not configure port: (22, 'Invalid argument')
body: <p>On Ubuntu 16.04 in VirtualBox, with a Beaglebone Black connected to a USB port, running the following code returns an error:</p>
  
  <pre><code>import serial
  
  ser = serial.Serial()
  ser.port = '/dev/sdb'
  ser.baudrate = 9600
  ser.open()
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Could not configure port: (22, 'Invalid argument')
  </code></pre>
  
  <p>I acquired the BBB's path using <code>blkid</code> in the terminal. The BBB is normally accessible using SSH in the virtual Machine.</p>
  
  <p>What is causing the error, why can't Python open the port? 
  <br/><br/><br/>
  <strong>Edit</strong> <br/><br/>
  The output of <code>blkid</code> is:</p>
  
  <pre><code>/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"
  </code></pre>
  
  <p>Where <code>/dev/sdb</code> is the BBB's path and <code>/dev/sdc1</code> the USB stick's path.</p>
  
  <p><br/></p>
  
  <p><code>ls -l /dev/sd*</code> returns:</p>
  
  <pre><code>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
  </code></pre>
  
  <p><br/></p>
  
  <p><code>lsblk</code> returns:</p>
  
  <pre><code>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
  </code></pre>