======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 NAME^PARAMETER(S)^RETURN^DESCRIPTION^ |[[.functions:f485open]]|int baud, int parity|int handle or 0|Open the RS-485 port at the specified baud rate and parity| |[[.functions:fclose]]|int handle||Close a file, stream or socket| |[[.functions:feof]]|int handle|int 1 or 0|Test if no more data is available in a file, stream or socket| |[[.functions:fgets]]|int handle, int size|string or int -1|Return a single line from a file, stream or socket, with optional size limit| |[[.functions:filesize]]|string filename or int handle|int bytes|Return the size of a file, or the number of unread bytes in a stream or socket| |[[.functions:fread]]|int handle, int bytes|string or int 0|Read bytes from a file, stream or socket| |[[.functions:fseropen]]|int baud, int blocking, int invert, int parity|int handle or 0|Open the serial port at the specified baud rate with optional parameters| |[[.functions:fwrite]]|int handle, mixed data, int length|int bytes written or -1|Write data to a file, stream or socket| |[[.functions:mb_delete_device]]|int id|int 1=OK|Delete a device from the list of active devices| |[[.functions:mb_get_dev_by_id]]|int id|array|Return modbus device details by id| |[[.functions:mb_get_dev_by_index]]|int index|array|Return modbus device details by index| |[[.functions:mb_get_dev_by_name]]|string name|array|Return modbus device details by name| |[[.functions:mb_get_dev_info]]|int type|array|Return modbus device details by type| |[[.functions:mb_get_role_array]]||array|Return an array of all roles and their values| |[[.functions:mb_get_status_by_role]]|int role|int 1=OK|Return status of the device attached to the role| |[[.functions:mb_get_val_by_role]]|int role|number|Return value of the role| |[[.functions:mb_num_devices]]||int|Return number of devices on the modbus| |[[.functions:mb_queue_command]]|mixed values ...|array of numbers|Queue a sequence of characters to the RS-485 bus and get but ignore the reply| |[[.functions:mb_scan_complete]]||int 1=complete, 0=ongoing|Check to see if a modbus scan has completed| |[[.functions:mb_scan_percent]]||number percent completed|Return scan percentage completed| |[[.functions:mb_send_command]]|mixed values ...|array of numbers|Send a sequence of characters to the RS-485 bus and get a reply| |[[.functions:mb_set_dev_var]]|string name or int id, string variable, mixed value|int 1=OK|Set a variable on a modbus device| |[[.functions:mb_set_val_by_role]]|int role, number value|int 1=OK|Set a role value on a modbus device| |[[.functions:mb_start_scan]]|int start, int end||Initiate an automatic scan of the modbus|