User Tools

Site Tools


uphp:functions:f485open

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

uphp:functions:f485open [2017/03/27 16:07]
jeff
uphp:functions:f485open [2021/09/13 05:57]
Line 1: Line 1:
-======f485open====== 
-<badge>WMPRO, WMMINI FW >= 1.922</badge> <badge>WMMEGA FW >= 2.0</badge> 
- 
-Open the RS-485 port at the specified baud rate and parity 
- 
-====Description==== 
-<well size="sm"><html><span style="font-size:125%;color:green;">int 
-<span style="color:black;"></html>[[f485open]] 
-<html>( 
-<span style="color:green;">int 
-<span style="color:blue;">$baud<span style="color:black;">, 
-<span style="color:green;">int 
-<span style="color:blue;">$parity 
-<span style="color:black;">) 
-</html></well> 
- 
-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:Serial Port Programming#Using the RS-485 Serial Port]]). 
- 
-====Parameters==== 
-<html><span style="color:blue;"><b>baud</b><span style="color:black;"></html>:  Rate in bits per second 
- 
-<html><span style="color:blue;"><b>parity</b><span style="color:black;"></html>:  0 (even parity) or 1 (odd parity) 
- 
-====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()]], [[fwrite()]], [[fclose()]] and [[feof()]] 
- 
-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,0); 
-  if (!$fp) { 
-    print("Serial open failed"); 
-  } else { 
-    $res=fwrite($fp,"Hello from wattmon"); 
-    if ($res) { 
-      print("An error occurred while trying to write to the port"); 
-    } 
-    fclose($fp); 
-  } 
-?> 
-</code> 
- 
-====See Also==== 
-[[how_tos:Serial Port Programming]] - Some information on connecting and using the serial ports 
- 
-[[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 
  
uphp/functions/f485open.txt · Last modified: 2021/09/13 05:57 (external edit)