read_buf()
Syntax
read_buf(id, length, dest[]);
Description
Reads received data from selected peripheral.
Parameters
Variable | Input |
|---|---|
| RS232 - Reads from RS232 peripheral. RS485 - Reads from RS485 peripheral. J1708 - Reads from J1708 peripheral. SMStext - Reads out SMS message. PhoneNumber - Phone number of received SMS message sender. Kline - Reads from Kline. Remote_Command - Reads command received from remote server. IMEI - Reads out device IMEI. SENSOR_STRING_X - Reads data from specific string sensor i.e. SENSOR_STRING_1. |
| Number of bytes to read. |
| Destination buffer where data is going to be written. |
Returns
Return value | Return explanation |
SCRIPT_OPERATION_SUCCESS | Success |
SCRIPT_OPERATION_FAILED | Failed |
SCRIPT_NO_ACCESS | Peripheral not initialized. |
SCRIPT_PARAM_INVALID | Passed parameters invalid. |
Function call example
Example of reading RS232 buffer
new str_temp[255];
main()
{
Init(RS232, 9600, WORDLENGTH_8, STOPBITS_1, PARITY_NONE); // Baud rate: 9600, Word length: 8bit, Stop bit: 1, Parity: none
for(;;)
{
if(buf_len(RS232)) // Check if there's anything on RS232 bus
{
read_buf(RS232, buf_len(RS232), str_temp); // Read `buf_len(RS232)` bytes to `str_temp` from RS232 bus
}
Delay(1000); // Delay 1 second
}
}