This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
uphp:functions:fseropen [2017/03/18 12:29] jeff created |
uphp:functions:fseropen [2021/09/13 05:57] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
======fseropen====== | ======fseropen====== | ||
- | < | + | |
+ | < | ||
Open the serial port at the specified baud rate with optional parameters | Open the serial port at the specified baud rate with optional parameters | ||
====Description==== | ====Description==== | ||
- | <well size=" | + | |
- | <span style=" | + | <well size=" |
- | < | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
- | <span style=" | + | <span style=" |
+ | <span style=" | ||
</ | </ | ||
+ | |||
+ | Attempt to open the serial port, and return the file handle for future operations | ||
====Parameters==== | ====Parameters==== | ||
- | < | ||
- | < | + | <html><b>< |
- | < | + | <html><b>< |
- | < | + | <html><b>< |
- | ====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 serial port fails it will return 0 | + | ====Return Values==== |
+ | < | ||
+ | |||
+ | The file handle may be used together with the other file functions that require a handle such as [[fgets()]], | ||
====Example==== | ====Example==== | ||
- | Open the serial port at 115200 baud in non-blocking mode: | + | |
+ | ===Open the serial port at 115200 baud in non-blocking mode=== | ||
<code php> | <code php> | ||
<? | <? | ||
- | $fp=fseropen(115200); | + | |
- | if ($fp) { | + | if ($fp) { |
- | $res=fwrite($fp," | + | $res=fwrite($fp," |
- | if ($res) { | + | if ($res) { |
- | print(" | + | print(" |
+ | } | ||
+ | fclose($fp); | ||
+ | } else { | ||
+ | print(" | ||
} | } | ||
- | fclose($fp); | ||
- | } else { | ||
- | print(" | ||
- | } | ||
?> | ?> | ||
</ | </ | ||
- | ====See Also==== | + | ====Also |
- | [[uphp: | + | |
- | [[f485open()]] - Open the RS-485 port as a stream | + | [[how_tos: |
- | + | ||
- | [[fsockopen()]] - Open an internet socket connection | + | |
[[fopen()]] - Open a file for reading or writing | [[fopen()]] - Open a file for reading or writing | ||
- | [[fclose()]] - Close a file, stream or socket | + | [[f485open()]] - Open the RS-485 port at the specified baud rate and parity |
- | [[feof()]] - Test if no more data is available in a file or stream | + | [[fsockopen()]] - Open an internet socket connection with optional timeout |
- | [[fgets()]] - Return a single line from a file or stream, with optional size limit | + | [[fread()]] - Read bytes from a file, stream |
- | [[fread()]] - Return | + | [[fgets()]] - Return |
- | [[fwrite()]] - Write data to a file or stream | + | [[fwrite()]] - Write data to a file, stream |
- | [[uphp: | + | [[feof()]] - Test if no more data is available in a file, stream or socket |
+ | |||
+ | [[filesize()]] - Return the size of a file, or the number of unread bytes in a stream or socket | ||
+ | |||
+ | [[fseek()]] - Position the file pointer in an open file | ||
+ | |||
+ | [[ftell()]] - Return the current position of a file read/write pointer | ||
+ | |||
+ | [[fclose()]] - Close a file, stream or socket | ||