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
$> stty -F /dev/ttyUSBx -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 115200
$> 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

$> stty -F /dev/ttyUSBx -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 115200
$> 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

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 - 2020-11-09


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

PuTTY: A Free Telnet/SSH Client
  1. http://www.chiark.greenend.org.uk/~sgtatham/putty
    • @GSI: use the "Softwarecenter" to install Putty.
  2. you have to find out which COM port the HadCon2 is connected to: e.g. COM14
    • e.g. "Windows+R" → "devmgmt.msc" → (COM & LPT), before and after connecting HadCon2
  3. settings:
    • basic options:

      putty basic settings
    • connection options:

      putty connection settings
    • terminal options:

      putty terminal options
  4. then open a serial session to the COM port, e.g. COM14


-- PeterZumbruch - 2019-04-26
-- PeterZumbruch - 2020-11-10
I Attachment Action Size Date Who Comment
hadconEXT hadcon manage 1 K 2014-01-07 - 18:08 PeterZumbruch hadcon
hadcon_command_only.pl.txttxt hadcon_command_only.pl.txt manage 2 K 2014-01-08 - 01:17 MichaelTraxler send commands via serial interface
hadcon_command_only_pl.txttxt hadcon_command_only_pl.txt manage 2 K 2014-01-08 - 01:18 MichaelTraxler send commands via serial interface
putty-serial_basic.PNGPNG putty-serial_basic.PNG manage 25 K 2020-11-10 - 17:32 PeterZumbruch putty basic settings
putty-serial_connection.PNGPNG putty-serial_connection.PNG manage 33 K 2020-11-10 - 17:32 PeterZumbruch putty connection settings
putty-serial_terminal.PNGPNG putty-serial_terminal.PNG manage 35 K 2020-11-10 - 17:33 PeterZumbruch putty terminal options
slurp_serialEXT slurp_serial manage 1 K 2014-01-07 - 18:09 PeterZumbruch slurp_serial
Topic revision: r19 - 2020-11-10, PeterZumbruch - This page was cached on 2024-05-26 - 09:40.

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 | Legal notice | Privacy Policy (german)