UARTAT Class
- ID: uartat
- Name: Generic AT Command Based UART Device
- Category: other
- Connection: uart
This is a generic UART device driver for accessing UART based devices that utilize an "AT" command set. Typically these devices are Radios, Modems, and similar devices that are configured and controlled by emitting "AT" commands.
Item Index
Methods
UARTAT
                      
                              - 
                                              uart
- 
                                              baudrate
UARTAT object constructor for a UART specified by MRAA number.
Parameters:
- 
                                              uartNumberSpecify which uart to use. 
- 
                                              baudrateNumberSpecify the baudrate to use. 
Returns:
UARTAT
                      
                              - 
                                              uart_path
- 
                                              baudrate
UARTAT object constructor for a UART specified by PATH (ex: /dev/ttyUSB0)
Parameters:
- 
                                              uart_pathStringSpecify path of UART device. 
- 
                                              baudrateNumberSpecify the baudrate to use. 
Returns:
readStr
                      
                              - 
                                              size
Read character data from the device.
Parameters:
- 
                                              sizeNumberThe maximum number of characters to read. 
Returns:
string containing the data read.
writeStr
                      
                              - 
                                              buffer
Write character data to the device.
Parameters:
- 
                                              bufferStringThe string containing the data to write. 
Returns:
The number of bytes written.
setBaudrate
                      
                              - 
                                              baudrate
Set the baudrate of the device.
Parameters:
- 
                                              baudrateNumberThe baud rate to set for the device. 
setResponseWaitTime
                      
                              - 
                                              wait_time
Set the default time, in milliseconds, to wait for data to arrive after sending a command.
Parameters:
- 
                                              wait_timeNumberThe response delay to set, in milliseconds. 
dataAvailable
                      
                              - 
                                              millis
Determine whether there is data available to be read. In the case of a UART, this function will wait up to "millis" milliseconds for data to become available. In the case of an I2C device, the millis argument is ignored and the function will return immediately, indicating whether data is available.
Parameters:
- 
                                              millisNumberThe number of milliseconds to wait for data to become available. 
Returns:
true if data is available to be read, false otherwise.
commandMode
                      
                              - 
                                              cmd_chars
- 
                                              guard_ms
Place the device in AT command mode. Many devices operate in a transparent mode and an AT command mode. Command mode is required to issue AT based commands. When in transparent mode, the device will usually listen for a special sequence of characters and delays, indicating that AT command mode should be entered.
                      On most devices, the sequence is: <wait 1 second>+++<wait 1 second>
                      For most devices, the wait time is 1 second (1000 ms) and the character sequence is "+++". These options can often be configured on the device.
                      This function will wait millis milliseconds, write the command characters (typically "+++"), then wait millis milliseconds again. At this time a read will be attempted, looking for the "OK" response indicating command mode was successfully entered.
Parameters:
- 
                                              cmd_charsStringThe character sequence to write, typically "+++". 
- 
                                              guard_msNumberThe number of milliseconds to delay before and after the cmd_chars are written. 
Returns:
true if AT command mode ("OK" detected) was successfully entered, false otherwise.
inCommandMode
                      
                              ()
                      
                              
                                  Boolean
                              
                      
                      
                      
                      
                      
                      
                      
                          
                      
                          Check to see if the device is in command mode. This is accomplished by sending an "AT\r" command and seeing if "OK" or "0" is returned.
Returns:
true if AT command mode was detected, false otherwise.
drain
                      
                              ()
                      
                      
                      
                      
                      
                      
                      
                      
                          
                      
                          Read and throw away any data currently available to be read. This is useful to avoid reading data that might have been the result of a previous command interfering with data you currently want to read. This function is automatically called by commandWithResponse() , command() , and commandWaitfor() prior to writing the requested command to the device.
commandWithResponse
                      
                              - 
                                              cmd
- 
                                              resp_len
Send an AT command and optionally return a response.
Parameters:
- 
                                              cmdStringA character string containing the AT command to send, including the "AT" prefix and a terminating carriage return ("\r"). 
- 
                                              resp_lenNumberThe maximum number of characters to read from the device. 
Returns:
The device response string, if any.
commandWaitFor
                      
                              - 
                                              cmd
- 
                                              resp_len
- 
                                              waitString
- 
                                              millis
Send an AT command and return a response, while waiting for a specific string. If the string isn't found the returned string will be empty. If the string is found, the function will return immediately.
Parameters:
- 
                                              cmdStringA character string containing the AT command to send, including the "AT" prefix and a terminating carriage return ("\r"). 
- 
                                              resp_lenNumberThe maximum number of characters to read from the device. 
- 
                                              waitStringStringThe string to look for. If found, the response will be returned immediately regardless of the timeout setting. 
- 
                                              millisNumberThe maximum number of milliseconds to wait for the string. 
Returns:
A string containing the response if the search string was found, otherwise and empty string is returned.
command
                      
                              - 
                                              cmd
Send an AT command and ignore any response.
Parameters:
- 
                                              cmdStringThe AT command to send, including the "AT" prefix and a terminating carriage return ("\r"). 
stringCR2LF
                      
                              - 
                                              str
This is a convenience method that converts each CR () in a string to a LF (
                      ) and returns it. This is useful for outputting the response to an AT command for instance, which is often CR terminated.
Parameters:
- 
                                              strStringThe string to convert 
Returns:
The converted string
setFlowControl
                      
                              - 
                                              fc
Set a flow control method for the UART. By default, during initialization, flow control is disabled.
Parameters:
- 
                                              fcUARTAT_FLOW_CONTROL_TOne of the UARTAT_FLOW_CONTROL_T values. 
find
                      
                              - 
                                              buffer
- 
                                              str
Look for a string in a buffer. This is a utility function that can be used to indicate if a given string is present in a supplied buffer. The search is case sensitive.
Parameters:
- 
                                              bufferStringThe string buffer in which to search. 
- 
                                              strStringThe string to search for. 
Returns:
true if the string was found, false otherwise.
filterCR
                      
                              - 
                                              enable
Filter out carriage returns (CR) from response buffers if enabled. This operates only on the response buffers returned from commandWithResponse() , command() , and commandWaitfor().
Parameters:
- 
                                              enableBooleantrue to filter out CR's, false otherwise