########################################################################## # This is an example and debug protocol file for StreamDevice. # # (C) 2010 Dirk Zimoch (dirk.zimoch@psi.ch) # # This file is part of StreamDevice. # # StreamDevice is free software: You can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # StreamDevice is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with StreamDevice. If not, see https://www.gnu.org/licenses/. #########################################################################/ # example stream protocol file Terminator = CR LF; ReplyTimeout = 10000; # 10 sec is very long, for keyboard input ReadTimeout = 1000; # also long for keyboard input binary { out "%B\x00\xff"; } # note the field access ai { out "%(NAME)s [int] ? "; in "%i"; # read to RVAL and convert } set-ao { out '%(NAME)s = %f %(EGU)s [0x%04x]'; } li { out "%(NAME)s [int] ? "; in "%i"; } lo { out '%(NAME)s = %i = %#x = %b(bin) = %D(BCD)'; } bi { out "%(NAME)s [0 or 1] ? "; in "%i"; } # using variables s0 = false; s1 = true; bo { out '%(NAME)s = %i = %{\${s0}|\${s1}} = "%s"'; } enums { out "%{choice0|choice1|choice2} %d %s"; } checksum { out "%s% sum"; out "%s% nsum"; out "%s%<-sum> -sum"; out "%s% notsum"; out "%s%<~sum> ~sum"; out "%s% xor"; out "%s% crc8"; out "%s% ccitt8"; out "%s% sum16"; out "%s% crc16"; out "%s% crc16r"; out "%s% ccitt16"; out "%s% ccitt16 with augment"; out "%s% sum32"; out "%s% crc32"; out "%s% crcr32"; out "%s% jamcrc"; out "%s% adler32"; out "%s%0 sum (ASCII)"; out "%s%0 nsum (ASCII)"; out "%s%0<-sum> -sum (ASCII)"; out "%s%0 notsum (ASCII)"; out "%s%0<~sum> ~sum (ASCII)"; out "%s%0 xor (ASCII)"; out "%s%0 crc8 (ASCII)"; out "%s%0 ccitt8 (ASCII)"; out "%s%0 sum16 (ASCII)"; out "%s%0 crc16 (ASCII)"; out "%s%0 crc16r (ASCII)"; out "%s%0 ccitt16 (ASCII)"; out "%s%0 ccitt16 with augment (ASCII)"; out "%s%0 sum32 (ASCII)"; out "%s%0 crc32 (ASCII)"; out "%s%0 crcr32 (ASCII)"; out "%s%0 jamcrc (ASCII)"; out "%s%0 adler32 (ASCII)"; out "%s%0 hexsum8 (ASCII)"; } command { out "%s"; } info { out "%s"; in "%39c"; } read { in "%39c"; } spy { extraInput=ignore; PollPeriod = 10; in "%39c"; } # accessing fields calcout { out "OVAL=%f A=%(A)f B=%(B)f C=%(C)f"; } scalcout { out "OVAL=%f SOV=%s A=%(A)f B=%(B)f AA=%(AA)s"; } # output an array of strings string_wave_out { separator = ", "; out "waveform %(NAME)s = (%s)"; } char_wave_in { outterminator = ""; out CR LF "Enter String: "; in "%1000c"; out 'Got: "%s"' CR LF; }