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:
- -opost
- do not post-process output
- -onlcr
- do not translate newline to carriage return-newline
- Local settings:
- -isig
- do not enable interrupt, quit, and suspend special characters
- -icanon
- do not enable erase, kill, werase, and rprnt special characters
- -iexten
- do not enable non-POSIX special characters
- -echo
- do not echo input characters
- -echoe
- do not echo erase characters as backspace-space-backspace
- -echok
- do not echo a newline after a kill character
- -echoctl
- do not echo control characters in hat notation ('^c')
- -echoke
- kill all line by obeying the
echoctl
and echok
setting
- 115200
- sets the speed to 115200 Bit/s
Summarizing the settings prevent any additional manipulation of input or output.
Linux
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
hadcon
IRC-like environment with command history (over several sessions) and command line editing all included
- requires
tmux
installed
- copy the following three commands to your
~/bin
$> 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
picocom --b 115200 -l /dev/ttyUSBx -d 8 -p n -f n --echo --omap crlf --imap lfcrlf
replace
x
by the corresponding integer
- Prerequisites
- you have to have admin rights.
- How to
-
- Links
-
- "Writing udev rules"
- http://reactivated.net/writing_udev_rules.html
- udev
- https://wiki.ubuntuusers.de/udev/
- "Tutorial on how to write basic udev rules in Linux"
- https://linuxconfig.org/tutorial-on-how-to-write-basic-udev-rules-in-linux
Windows
Beginning with version
4.6.2
a fix provides also direct access for Windows.
PuTTY: A Free Telnet/SSH Client
- http://www.chiark.greenend.org.uk/~sgtatham/putty
- @GSI: use the "Softwarecenter" to install Putty.
- 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
- settings:
- basic options:
- connection options:
- terminal options:
- then open a serial session to the COM port, e.g.
COM14
LabVIEW