Epics@GSI Webhome

HadCon 2 Multipurpose Controls Api Basic Operation

Basic Operation Principles

The basic operation principle is that
  • Any device communicates via the USB interface with the μController sending and receiving keyword based ASCII streams/strings (see Protocol for details)
    • input string is terminated by <LF> or <CR>
  • μController provides the communication with the (external) devices

  • In general a command and its possible response e.g. HELP is sent/retrieved from the master to the ATMEL with e.g. by listening to /dev/ttyUSBx while sending the command to the same device, i.e. in the easiest case (including an endless while loop for an automatic reconnect)
    $> while :; do sleep 1; cat /dev/ttyUSBx; done &
    $> echo "HELP" >/dev/ttyUSBx
    replace x by the corresponding integer
  • To access the device the user has to have the right permissions, e.g. dialout, use ls and groups to find out current settings
    $> ls -l /dev/ttyUSB*
    crw-rw-rwT 1 root users 188, 0 Jan 21 10:38 /dev/ttyUSB0
    crw-rw---T 1 root dialout 188, 1 Jan 21 10:38 /dev/ttyUSB1

    $> groups epics
    epics : epics dialout epicsadm
  • It might be necessary that the properties of the serial devices has to be changed. Currently these stty are working
    $> stty -F /dev/ttyUSBx -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 115200

    • Output settings:
      do not post-process output
      do not translate newline to carriage return-newline
    • Local settings:
      do not enable interrupt, quit, and suspend special characters
      do not enable erase, kill, werase, and rprnt special characters
      do not enable non-POSIX special characters
      do not echo input characters
      do not echo erase characters as backspace-space-backspace
      do not echo a newline after a kill character
      do not echo control characters in hat notation ('^c')
      kill all line by obeying the echoctl and echok setting
      sets the speed to 115200 Bit/s

    Summarizing the settings prevent any additional manipulation of input or output.

Communication Tools


cat / echo
$> while :; do sleep 1; cat /dev/ttyUSBx; done; &
$> echo "HELP" >/dev/ttyUSBx
replace x by the corresponding integer

IRC-like environment with command history (over several sessions) and command line editing all included

$> hadcon /dev/ttyUSBx
replace x by the corresponding integer

picocom --b 115200 -l /dev/ttyUSBx -d 8 -p n -f n --echo --omap crlf --imap lfcrlf

replace x by the corresponding integer

udev/usbdev - dynamic device symbolic link and proper access rights

you have to have admin rights.

How to
  • edit/create /etc/udev/rules.d/99-serial-permissions.rules
    • add the follwing line for general includes
      SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", SYMLINK+="$env{ID_SERIAL}", GROUP="users", MODE="0666"
      creates for every connected device of vendor id 0403 a symbolic link /dev/ to the connected device
    • for special devices those lines can be added in addition
      SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ENV{ID_SERIAL}=="FTDI_FT232R_USB_UART_A100dQ2B", SYMLINK+="hadcon2", GROUP="users", MODE="0666"
      SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ENV{ID_SERIAL}=="FTDI_FT232R_USB_UART_A600801P", SYMLINK+="olimex", GROUP="users", MODE="0666"

    • for special devices (e.g. HadCon2) those lines can be added in addition
      • SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ENV{ID_SERIAL}=="FTDI_FT232R_USB_UART_A100*", RUN+="/usr/bin/stty -F /dev/$kernel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 115200 "
      • SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ENV{ID_SERIAL}=="FTDI_FT232R_USB_UART_A801*", RUN+="/usr/bin/stty -F /dev/$kernel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 115200 "
  • to find out the IDs of connected systems
    udevadm info --export-db| grep FTDI| grep ID_SERIAL

  • Finally reload rules and trigger a reconnect:
    udevadm control --reload-rules
    udevadm trigger

"Writing udev rules"
"Tutorial on how to write basic udev rules in Linux"

-- PeterZumbruch - 2019-03-22


Beginning with version 4.6.2 a fix provides also direct access for Windows.

PuTTY: A Free Telnet/SSH Client

  • you have to find out which COM port the HadCon2 is connected to: e.g. COM14
    • e.g. "Windows+R" → "devmgmt.msc" → (COM &amp LPT), before and after connecting HadCon2
  • settings:
    • basic options:

      putty basic settings
    • connection options:

      putty connection settings
    • terminal options:

      putty terminal options


-- PeterZumbruch - 2018-02-21
-- PeterZumbruch - 2018-02-21
Topic attachments
I Attachment Action Size Date Who CommentSorted ascending
hadconEXT hadcon manage 1.3 K 2014-01-07 - 17:08 PeterZumbruch hadcon
putty-serial_basic.PNGPNG putty-serial_basic.PNG manage 20.5 K 2014-01-13 - 15:08 PeterZumbruch putty basic settings
putty-serial_connection.PNGPNG putty-serial_connection.PNG manage 26.5 K 2014-01-13 - 15:10 PeterZumbruch putty connection settings
putty-serial_terminal.PNGPNG putty-serial_terminal.PNG manage 26.3 K 2014-01-16 - 10:17 PeterZumbruch putty terminal options
hadcon_command_only.pl.txttxt hadcon_command_only.pl.txt manage 2.8 K 2014-01-08 - 00:17 MichaelTraxler send commands via serial interface
hadcon_command_only_pl.txttxt hadcon_command_only_pl.txt manage 2.8 K 2014-01-08 - 00:18 MichaelTraxler send commands via serial interface
slurp_serialEXT slurp_serial manage 1.6 K 2014-01-07 - 17:09 PeterZumbruch slurp_serial
Topic revision: r14 - 2018-02-21, PeterZumbruch
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GSI Wiki? Send feedback
Imprint (in German)
Privacy Policy (in German)