Contents - Index


Serial. (Macro Commands)

 

Serial.Close COM1

Close serial port COM1. The port name, COM1 in this example, can be a string variable, e.g., C$, that has been previously set to the port name.  If the specified serial port is not open, this command will do nothing.

 

Serial.Open  Port=COM1 Baud=9600  Parity=n  Stop=1  BufferSize=2048 TimeOut=200

Opens serial port COM1 for reading and/or writing.  The port name, COM1 in this example, can be a string variable, e.g., C$, that has been previously set to the port name.   The baud rate is the number of bits per second that data is transferred in serial communication.  Parity and Stop specify framing bits for the asynchronous communication. The baud rate, parity, and stop bits  must match the parameters of the device that EES is attempting to communicate with.  The defaults for Baud, Parity, and Stop are 9600, n, and 1.  If these parameters are not provided, the defaults are used.  Buffersize is the number of bytes used for the internal buffers for reading and writing.  The maximum buffer size is 8192.  If butfersize is set to zero or if this parameter is not provided, the default buffersize of 1024 is used.  TimeOut is the number of milliseconds that EES will wait before giving up while trying to read data from the serial port with the Serial.ReadChar Serial.ReadString, Serial. ReadNumber or  Serial.ReadtoLookup serial macro commands.   Timeout can be specified with a number or with an EES variable that has previously been set to value.  The choice for Timeout depends on the rate at which the serial device is sending data.  The Pause macro can also be used within a Repeat-Until loop to control the timing.  (See Using a Macro for Serial Port Communications)

 

Serial.ReadChar COM1 H$

Reads a single ASCII character from the specified serial port.  The first parameter is the port name, COM1 in this example, and it can be a string variable, e.g., C$, that has been previously set to the port name. The specified port must have been previously opened with the Serial.Open command.  An EES string variable, e.g., H$, must be provided.  The string variable will be set to the character read from the serial port.

 

Serial.ReadNumber COM1 V

Reads a numerical value (integer or real) from the specified serial port.  The first parameter is the port name, COM1 in this example, and it can be a string variable, e.g., C$, that has been previously set to the port name. The specified port must have been previously opened with the Serial.Open command.  An EES variable, e.g., V, must be provided.  The value of the variable will be set to the numerical value read from the serial port.  Note that the numerical value is provided to the serial port by the external program as a string of numerical characters terminated by CRLF, i.e., carriage return (ASCII13) and line feed (ASCII 10) characters.  The ReadNumber macro command will continue to look for the number on the serial port until it reads a CRLF or the Timeout interval specified in the Serial.Open command is exceeded.

 

Serial.ReadString COM1 S$ 

Reads a string consisting a one or more ASCII characters from the specified serial port.  The first parameter is the port name, COM1 in this example, and it can be a string variable, e.g., C$, that has been previously set to the port name. The specified port must have been previously opened with the Serial.Open command.  An EES string variable, e.g., S$, must be provided.   The string variable will be set to the character string read from the serial port.  Note that string provided to the serial port by the external program must be terminated by CRLF, i.e., carriage return (ASCII13) and line feed (ASCII 10) characters.  The ReadString macro command will continue to look for the string on the serial port until it reads a CRLF or the Timeout interval specified in the Serial.Open command is exceeded.

 

Serial.ReadtoLookup COM1 'TableName'  Row Col

Reads a numerical value from the specified serial port directly into a specified cell of a specified Lookup table.  The first parameter is the port name, COM1 in this example, and it can be a string variable, e.g., C$, that has been previously set to the port name.  The specified port must have been previously opened with the Serial.Open command.  The second parameter, TableName, is the name of the Lookup table that appears on the tab of the Lookup table.  TableName can be either a string constant or string variable.  The Lookup table must exist.  It can be created using the New Lookup Table menu or the NewLookup macro command.  Row and Col are respectively, the row and column in which the numerical value will be placed after the read operation is completed.  Row and Col can be provided as numerical values or as EES variables that have been previously set to numerical values.  The column can also be indicated by providing the column name as a string constant.  If Row is greater than the number of rows in the table, the number of rows is increased.  However, this operation takes time and may result in lost data.  It is better to use the InserLookupRows macro command to ensure that there are sufficient rows in the designated lookup table.  If Col is greater than the number of columns in the table, the value will be ignored.  Note that the numerical value is provided to the serial port by the external program as a string of numerical characters forming a single numerical value terminated by CRLF, i.e., carriage return (ASCII13) and line feed (ASCII 10) characters.  The ReadtoLookup macro command will continue to look for the number on the serial port until it reads a CRLF or the Timeout interval specified in the Serial.Open command is exceeded.

 

Serial.WriteChar COM1 'H'

Writes one or more ASCII characters to the specified serial port.  The first parameter is the port name, COM1 in this example, and it can be a string variable, e.g., C$, that has been previously set to the port name. The specified port must have been previously opened with the Serial.Open command. The second parameter is a string constant (enclosed within single quotes) or an EES string variable containing the character(s) that are to be written. Note that this command differs from the Serial.WriteString command in that CRLF (carriage return line feed characters) are not written to the serial port.

 

Serial.WriteNumber COM1 V

Writes the ASCII characters representing a number to the specified serial port.  The first parameter is the port name, COM1 in this example, and it can be a string variable, e.g., C$, that has been previously set to the port name. The specified port must have been previously opened with the Serial.Open command. The second parameter is either the numerical value or an EES variable, e.g., V, containing the numerical value that is to be written. CRLF (carriage return line feed characters) are appended to the number that is written to the serial port.

 

Serial.WriteString COM1 S$

Writes one or more ASCII characters to the specified serial port.  The first parameter is the port name, COM1 in this example, and it can be a string variable, e.g., C$, that has been previously set to the port name. The specified port must have been previously opened with the Serial.Open command. The second parameter is a numerical value or an EES string containing the character(s) that are to be written. Note that this command differs from the Serial.WriteChar command in that CRLF (carriage return line feed characters) are appended to the characters that are written to the serial port.

 

MacroCommands