Skip to content
QiTASC.com / intaQt Built-ins /
Serial Built-ins
/ .. /
Serial Built-ins





Serial Built-ins

Serial Built-ins send AT commands to any serial device data sticks using intaQt's Steps language. For proper device usage, refer to the data stick's user manual. Additionally, the Serial built-in must be configured if using the Speech Channel Module.

Configuration

A dedicated configuration called Serial must be added to an intaQt configuration file. Each serial port requires its own serial configuration.

Syntax

1
2
3
4
5
6
7
8
Serial {
    <name String> {
        port = <String>
        rate = <Number>
        params = <Number>
        timeoutMillis = <Number>
    }
}

Parameters

  • name - The name assigned to the serial port configuration

    • Any name may be chosen, but if the name starts with speech, intaQt will interpret the device as a Speech Channel Module
  • port - The serial port being used

  • params - The set of serial configuration parameters relating to databits, parity and stopbits

  • timeoutMillis (optional) - The timeout in milliseconds that Serial Built-ins wait after sending a command

Example

1
2
3
4
5
6
7
8
Serial {
    "huawei" {
        port = "/dev/ttyUSB0"
        rate = 9600
        params = "8N1"
        timeoutMillis = 30000
    }
}

Important! Windows uses a COM port with a number that may change when connecting the same device to another of the PC's USB ports.

Finding the Correct Serial Port

Depending on the platform, the serial port can be manually found one of the following ways:

  • For Windows, this information is provided by the device manager that displays all serial ports (called COM ports).

  • For Linux, the command /dev/tty* shows all serial ports. Next, type the output (For example, /dev/ttyUSB0 or /dev/ttyACM0). Note that the list might be quite long.

  • For Mac OS, entering ls /dev/cu.* into Terminal shows all serial ports. Next, type the output (for example, /dev/cu.ttyUSB0)  Note: Serial terminal software (such as Putty for Windows or Minicom for Linux) can also be used to find the USB serial port.

Using Serial Built-ins

Serial Built-ins return an object that communicates with a device via the serial port. This object supports two methods: sendAndReceive and fire.

Send and Receive

The sendAndReceive method sends a text string to the serial interface. It then waits for a response and returns it as a SerialCommunicationResult.

Syntax

1
<connection Object> := Serial.port(<portIdentifier String>).sendAndReceive(<text String>)

Returns
A response as a SerialCommunicationResult object. A CRLF (carriage return line feed) is appended automatically to the text string if not yet given.

Parameters

  • portIdentifier - The USB port, as defined in the configuration file

  • text - The text string being sent to the serial port

Example

1
2
3
4
5
6
7
8
stepdef "send an AT command"
    resp := Serial.port("huawei").sendAndReceive("ATI")
    if resp.isOK() then
        println("Response=" + resp.getContent())
    else
         println("FAILURE: " + resp.getContent())
    end
end

A SerialCommunicationResult is returned by sendAndReceive and supports the methods below:

  • response.isOK() - true if response is valid, false otherwise.

  • response.isNOK() - true if communication failed, false otherwise.

  • response.getContent() - Retrieves the response as a string. If the communication fails, the string contains an error message.

Fire

The fire method sends a string over the serial connection and ignores any response.

Syntax

1
2
<connection Object> := Serial.port(<portIdentifier String>)
<connection>.fire(<text String>)

Returns
The serial connection object.

Parameters

  • portIdentifier - The USB port, as defined in the configuration file

  • text - The text being sent to the serial port

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
stepdef "send an AT command"
    serialConn := Serial.port("huawei")
    serialConn.fire("AT^CURC=0")
    resp := serialConn.sendAndReceive("ATI")
    if resp.isOK() then
        println("Response=" + resp.getContent())
    else
        println("FAILURE: " + resp.getContent())
        assert false
    end
end