This shows you the differences between two versions of the page.
uphp:functions:f485open [2017/03/27 16:07] jeff |
uphp:functions:f485open [2021/09/13 05:57] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======f485open====== | ||
- | < | ||
- | |||
- | Open the RS-485 port at the specified baud rate and parity | ||
- | |||
- | ====Description==== | ||
- | <well size=" | ||
- | <span style=" | ||
- | < | ||
- | <span style=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | <span style=" | ||
- | </ | ||
- | |||
- | Attempt to open the RS-485 port as a stream, and return the file handle for future operations | ||
- | |||
- | In order to use the RS-485 port, you need to disable modbus polling (see [[how_tos: | ||
- | |||
- | ====Parameters==== | ||
- | < | ||
- | |||
- | < | ||
- | |||
- | ====Return Value==== | ||
- | Upon success it returns a file handle which may be used together with the other file functions that require a handle such as [[fgets()]], | ||
- | |||
- | If the attempt to open the RS-485 port fails it will return 0 | ||
- | |||
- | |||
- | ====Example==== | ||
- | **Open the 485 port at 115200 baud with even parity:** | ||
- | |||
- | <code php> | ||
- | <? | ||
- | $fp=f485open(115200, | ||
- | if (!$fp) { | ||
- | print(" | ||
- | } else { | ||
- | $res=fwrite($fp," | ||
- | if ($res) { | ||
- | print(" | ||
- | } | ||
- | fclose($fp); | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | |||
- | ====See Also==== | ||
- | [[how_tos: | ||
- | |||
- | [[fseropen()]] - Open the serial port at the specified baud rate with optional parameters | ||
- | |||
- | [[fsockopen()]] - Open an internet socket connection with optional timeout | ||
- | |||
- | [[fopen()]] - Open a file for reading or writing | ||
- | |||
- | [[fclose()]] - Close a file, stream or socket | ||
- | |||
- | [[feof()]] - Test if no more data is available in a file or stream | ||
- | |||
- | [[fgets()]] - Return a single line from a file or stream, with optional size limit | ||
- | |||
- | [[fread()]] - Return bytes from a file or stream | ||
- | |||
- | [[fwrite()]] - Write data to a file or stream | ||