Skip to content

Instantly share code, notes, and snippets.

@priithansen
Created March 30, 2012 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save priithansen/2251372 to your computer and use it in GitHub Desktop.
Save priithansen/2251372 to your computer and use it in GitHub Desktop.
Makibot php
<?php
include "php_serial.class.php";
$go = $_GET["go"];
// Let's start the class
$serial = new phpSerial;
// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
$serial->deviceSet("/dev/cu.usbserial-A4007mX9");
// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
// Then we need to open it
$serial->deviceOpen();
// To write into
$serial->sendMessage($go);
// Or to read from
//$read = $serial->readPort();
// If you want to change the configuration, the device must be closed
$serial->deviceClose();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment