2019-06-12

Serial port communication on Mac with SCREEN command


Use screen command to communicate with Serial port

  1. Open Terminal or iTerm2
  2. See if the serial port exists
    $ ls -l /dev/cu.*
    crw-rw-rw-  1 root  wheel   20,   1 Jun 10 21:07 /dev/cu.Bluetooth-Incoming-Port
    crw-rw-rw-  1 root  wheel   20,   3 Jun 12 18:13 /dev/cu.usbmodem1421401
    
  3. Connect to the port
    $ screen -L /dev/cu.usbmodem1421401 115200
    -L : show log of the command from the serial port
  4. Other commands
    # in a running session
    Ctrl-A, K : kill the session
    Ctrl-A, D : detach from the session
    
    # out of session
    $ screen -ls : list sessions
    
    There is a screen on:
    9244.ttys001.Dee15S (Attached)
    
    Format : [PID].[TTYID].[HOSTNAME]
    
    $ screen -r : attach the default session
    $ screen -r [NAME] : attach to a session named [NAME]
    $ screen -S [NAME] : attach to a session named [NAME]
    $ screen -d [ID] : detach from the session with screen id [ID]
    

No comments:

Post a Comment