serial tryfile - part-cw/lambdanative GitHub Wiki
(serial-tryfile filepath)
serial-tryfile attempts to open the serial port with a file. It is used to read binary data saved from a serial data dump using the rawoutput plugin. Otherwise it the returned device handle behaves just like one made with (serial-try devname baudrate databits parity stopbits testproc).
Parameter | Description |
---|---|
filepath | Full path to the file to be opened |
Example
Example 1: Connect to a binary file if fromfile flag is set, otherwise make a normal serial connection. This example derives from a plugin, in which a handshake is done over a serial connection.
((fx= runlevel 1)
(if fromfile
;; From a file, so connect to file
(let* ((filepath (instance-refvar group instance "Port" #f))
(dev (serial-tryfile filepath)))
(if dev (begin (instance-setvar! group instance "Device" dev) 2) 0))
;; Not from a file, so connect normally
(let* ((devname (instance-refvar group instance "Port" #f))
(baudrate 9600) (databits 8) (parity 0) (stopbits 1)
(dev (serial-try devname baudrate databits parity stopbits #f)))
(if dev (begin (instance-setvar! group instance "Device" dev) 2) 0))
))