on-internet
← Community

How to write to serial port using PHP? Having an issue with buffering

Stack Overflow ·

EDIT: I have done some testing with the following script (found here: PHP serial port data return from Arduino). It appears that even using fwrite to /dev/ttyUSB0 outputs my new command plus the last command sent from the device. This makes me think that maybe the serial port was not set up correctly (e.g. might need to use stty to change settings to clear the buffer) or there is something else I need to do (with php) to clear the buffer at /dev/ttyUSB0 before sending a new command. Any help would be appreciated, thanks. $fp =fopen("/dev/ttyUSB0", "w+"); if( !$fp) { echo "Error";die(); } fwrit

Comments

Sign in or sign up to comment and upvote.

No comments yet.