SCOMM is another UNIX terminal utility program to provide communications through a serial port. SCOMM is new (2014), has been implemented in C on MacOSX, and is intended for providing communication with legacy serial interfaces, devices and systems.

SCOMM sets as an objective the ability to have full two-way binary transparency through the communication port, in addition to text-oriented functionality. This allows for example, SCOMM to emulate an ASR-33 teletype where text functionality is desired for console or terminal operations as well as emulating the paper-tape punch and reader of the ASR-33 where full 8-bit binary transfer is required. A related objective is providing a fairly fine-grain level of control over character-handling such as new-line translation.

SCOMM was written because the "screen" program of MacOSX, despite it's complexity, still didn't provide - or guarantee - certain requirements, and I was too lazy to go looking for another program.

If SCOMM doesn't provide some desired facility, the source is available to hack.

Contents (this page): Resources:


Functional Overview

The diagram shows the structure and primary dataflow of SCOMM. A two-way transparent binary path through the communication port is established from SCOMM.

The main process - the sender - reads bytes from the user input (stdin) and writes them to the port. The sender may be switched from this 'send state' to the 'command state', to execute SCOMM commands entered by the user. Files may also be sent to the port.

A child process - the receiver - is created to read bytes from the port and write them to the user display (stdout). Non-printing bytes from the port may be displayed in hex. The binary data from the port may be directed for collection in a file. The sender process controls the receiver process through a pipe and signalling.

At startup, the sender is in the send state. Command state is entered by typing CTL-A. Terminating a command with CTL-A executes the command and continues in the command state. Terminating a command with RETURN executes the command and returns to the send state. Rudimentary line-editing is provided in command state.

In send state, the sender may operate in either character-immediate mode or line-at-a-time mode:

The default sender mode is character-immediate with echo enabled.


Use

scomm [-u] [-d commDevice] [-s speed] [-b bits] [-c] [-cmd arg*]*

-u : Display usage line.
-d commDevice : Specify the serial communication port device. The default device is "/dev/tty.usbserial".
A special device - "loopback" - is provided for testing without a hardware device. Another special device is "sbb" - see Teletype Support.
-s speed : Set the port speed. speed is a numeric value, accepted values are system-dependant.
-b bits : Set the number of data bits and stop bits for the port. bits may be 5, 6, 7, 8, 52, 62, 72 or 82.
If 52 is specified, translation to and from ITA2 character code is performed, for use, of course, with 5-level teletypes.
10xx = set CTS output flow control (CTS_OFLOW flag).
20xx = set carrier flow control (MDMBUF flag).
-c : Enter command mode at startup rather than send mode.
-cmd arg* : The SCOMM command cmd with any arguments is executed. Arguments cannot begin with a "-".

At startup:

To quit SCOMM, enter CTL-D in either send or command state, or the quit or exit command. If quit or exit is specified in the invokation command line, SCOMM will not terminate until subsequent commands in the command line have been executed.


Commands

The following commands may be entered when in command state:

Commands Affecting Sending:

sl*ine [off] : Set sender mode to line-at-a-time or character-immediate (off).
Initial state: character-immediate.
se*cho [off] : Enable/disable echoing in sender character-immediate mode. Echoing is always performed in line-at-a-time mode.
Initial state: on.
sknl [off|cr|crlf] : Set sender keyboard NL->CRLF translation mode. When off, Carriage-Returns and Line-Feeds from the keyboard are transparently sent to the port. In cr mode, a CR or LF from the keyboard sends a CR. In crlf mode (default), a CR or LF from the keyboard sends a CRLF pair.
Initial state: off.
sfnl [off|cr|crlf] : Same as sknl but for characters from send-files rather than the keyboard.
Initial state: off.
sfcrd*elay [mS] : Delay for mS milli-seconds after sending a CR.
Initial/default: 0.
sfnln*ulls [num] : Send num nulls after a NL, if NL translation is enabled.
Initial/default: 0.
sf*ile [+e] file : Send the contents of the specified file to the port. If +e is specified, the contents are also echoed to the display.
sby*tes num* : Send each numeric value as a byte.
srep*eat string [num] : Send string repeatedly, num times. num defaults to 1.
sbr*eak duration : Send break. duration is system dependant (see GNU tcsendbreak).
Device/system dependant (see Anomylies).
test*path [clean] : Send bytes of value 0 to 255 to the port. With the port serial line wired in loopback this provides a means to test the port for binary transparency. A new-line will be sent every 16 bytes, in accordance with the keyboard new-line mode, unless the optional argument is specified, in which case only the 256 byte-values are sent. Normally it will be desirable to have the receiver in display hex = all and display new-line = crlf modes to provide full display and separation of lines.

Commands Affecting Receiving:

rdhex [off|all] : Control the receiver hex display mode. Characters or bytes may be classed in 3 categories: text, control, and undefined. Recognised control characters are CR, LF, HT and NULL. Undefined characters are the remaining non-text, non-control byte values. If hex display is off, undefined characters are presented to the display transparently (as a binary byte). If hex display is on, undefined characters are displayed in hex. If all is specified, both undefined and control characters are displayed in hex, control characters nonetheless continuing to have their normal effect.
Initial state: on.
rdnl [off] : Enable/disable receiver CRLF->NL translation for the display. When enabled, incoming Carriage-Returns and Line-Feeds on their way to the display are translated to New-Lines, with the exception that a LF immediately following a CR is ignored.
Initial state: off.
rfnl [off] : Same as rdnl but affects data on its way to a collecting file rather than the display.
Initial state: off.
rdi8 [off] : When this mode is enabled the eighth bit is ignored as bytes are being processed for display. This is an allowance for external sources which insist on sending a parity bit.
rf*ile [[+s] file] : Collect received bytes in the specified file. +s suppresses the normal display of received bytes for the duration of the collecting. If no arguments are specified, collecting is terminated.

Miscellaneous Commands:

code [ita*2] : Set character code translation. ITA2 is the only alternative to ASCII currently provided.
Initial state: ASCII.
s*tatus : Display current status & mode info.
h*elp | ? : Display a command summary.
q*uit | exit : Terminate SCOMM.


Teletype Support:

SCOMM includes functionality for communication with old teletypes:


ASR-33 Emulation

To emulate an ASR-33 teletype with paper tape reader and punch, acting as a console or terminal for an attached computer system, and assuming a full-duplex connection in which the attached system does echoing:

scomm -d sbb -s 110 -b 82 -secho off

The send-file and receive-file commands are then used for paper-tape read and punch operations, with 8-bit transparency between the files and the attached system.


Anomylies / Bugs:

  1. ADVISORY: In sender line-at-a-time mode, a partially-entered line will be discarded if command state is entered.
  2. ADVISORY: SCOMM attempts to visually separate SCOMM command and information data from port data on the display but because two processes write to the display, data can end up being inter-mixed.
  3. ADVISORY: Sending a file may indicate completion before transmission is complete due to bufferring. tcdrain() is used but appears to not be effective with some devices, notably with USB serial devices.
  4. ADVISORY: Numeric values to the sbytes command go through code translation before sending - not what might be expected.
  5. Currently the only way to interrupt a long send is to kill SCOMM (CTL-C or CTL-Z & kill). This still may not terminate transmission due to device bufferring, notably with USB serial devices. tcflush() seems ineffective. Restarting at a high speed such as 76800 will sometimes work to flush out the buffer quickly.
  6. Sendbreak may not work on some devices or systems.
  7. BUG: Arguments on the command line which are not prefixed by a "-" but follow the device config options are not flagged as errors.


  SCOMM bhilpert
2014 Oct