Definition
flange_serial_read(timeout=None, port=1)
Features
This function reads the data from a flange serial port.
When using the Modbus RTU communication method, a minimum delay of 250 milliseconds is required after a write operation before receiving a read response. Instead of repeatedly calling flange_serial_read() or using the wait() function for the delay, you may add a timeout parameter to the function to handle the wait internally. However, the timeout value should be set slightly higher (e.g., 1 second) to ensure successful data reception within the minimum required time.
Parameters
|
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
|
timeout |
float int |
None |
Read waiting time |
|
port |
int |
1 |
Port number to read X1 Port: 1 X2 Port: 2 (Not available for A Series) |
Return
|
Value |
Description |
|---|---|
|
res |
Number of bytes of the received data -1 : time out -2 : overflow |
|
rx_data |
Number of bytes read (byte type) |
Exception
|
Exception |
Description |
|---|---|
|
DR_Error (DR_ERROR_TYPE) |
Parameter data type error occurred |
|
DR_Error (DR_ERROR_RUNTIME) |
C extension module error occurred |
|
DR_Error (DR_ERROR_STOP) |
Program terminated forcefully |
Example
# Sample 1. Wait using wait
# 2F-85 Gripper - Close the Gripper at full speed and full force
flange_serial_write(modbus_send_make(b"\x09\x10\x03\xE8\x00\x03\x06\x09\x00\x00\xFF\xFF\xFF"))
wait(0.25)
res, data = flange_serial_read(1,1)
# Sample 2. Wait using timeout
# 2F-85 Gripper - Close the Gripper at full speed and full force
flange_serial_write(modbus_send_make(b"\x09\x10\x03\xE8\x00\x03\x06\x09\x00\x00\xFF\xFF\xFF"))
res, data = flange_serial_read(1,1)