INSTALL:
- gem install serialport-server
SYNOPSIS:
- % serialport-server --help
- % serialport-server /dev/tty.usb-device
=> start HTTP, WebSocket, TCP Socket servers.
DEMO:
- Install Arduino Program
- Put LED(Digital 13), CdS(Analog 0) and 10kΩ
- Run serialport-server
% serialport-server /dev/tty.usb-device
- Open Ajax Demo
- Open WebSocket Demo
HTTP Interface:
read serialport
- % curl http://localhost:8783
write
- % curl -d 'hello!!' http://localhost:8783
WebSocket Interface:
// JavaScript
var ws = new WebSocket("ws://localhost:8784");
ws.onmessage = function(e){
alert(e.data);
};
ws.send('hello!!');
TCP Socket Interface: