Serial and Modbus Function Reference

uPHP functions related to the serial port and Modbus are shown below:

Click on the function name for further details:

FUNCTION NAMEPARAMETER(S)RETURNDESCRIPTION
f485openint baud, int parityint handle or 0Open the RS-485 port at the specified baud rate and parity
fcloseint handleClose a file, stream or socket
feofint handleint 1 or 0Test if no more data is available in a file, stream or socket
fgetsint handle, int sizestring or int -1Return a single line from a file, stream or socket, with optional size limit
filesizestring filename or int handleint bytesReturn the size of a file, or the number of unread bytes in a stream or socket
freadint handle, int bytesstring or int 0Read bytes from a file, stream or socket
fseropenint baud, int blocking, int invert, int parityint handle or 0Open the serial port at the specified baud rate with optional parameters
fwriteint handle, mixed data, int lengthint bytes written or -1Write data to a file, stream or socket
mb_delete_deviceint idint 1=OKDelete a device from the list of active devices
mb_get_dev_by_idint idarrayReturn modbus device details by id
mb_get_dev_by_indexint indexarrayReturn modbus device details by index
mb_get_dev_by_namestring namearrayReturn modbus device details by name
mb_get_dev_infoint typearrayReturn modbus device details by type
mb_get_role_arrayarrayReturn an array of all roles and their values
mb_get_status_by_roleint roleint 1=OKReturn status of the device attached to the role
mb_get_val_by_roleint rolenumberReturn value of the role
mb_num_devicesintReturn number of devices on the modbus
mb_queue_commandmixed values ...array of numbersQueue a sequence of characters to the RS-485 bus and get but ignore the reply
mb_scan_completeint 1=complete, 0=ongoingCheck to see if a modbus scan has completed
mb_scan_percentnumber percent completedReturn scan percentage completed
mb_send_commandmixed values ...array of numbersSend a sequence of characters to the RS-485 bus and get a reply
mb_set_dev_varstring name or int id, string variable, mixed valueint 1=OKSet a variable on a modbus device
mb_set_val_by_roleint role, number valueint 1=OKSet a role value on a modbus device
mb_start_scanint start, int endInitiate an automatic scan of the modbus