実際のところ
Processing
/** * Sttings. * * Robot Arm showing UI. */ import processing.net.*; int port = 10002; boolean myServerRunning = true; int bgColor = 0; int direction = 1; int textLine = 60; int rad = 60; int[] dataArray = {0,0,0}; Server myServer; void setup() { size(640, 360); noStroke(); myServer = new Server(this, port); // Starts a myServer on port 10002 background(102); //Window clear text("server", 15, 45); } void mousePressed() { // If the mouse clicked the myServer stops myServer.stop(); myServerRunning = false; } void draw() { if (myServerRunning == true) { Client thisClient = myServer.available(); if (thisClient != null) { if (thisClient.available() > 0) { // text("mesage from: " + thisClient.ip() + " : " + thisClient.readString(), 15, textLine); //textLine = textLine + 35; dataArray = int(split(thisClient.readString(), ",")); println(dataArray); background(102); text("server", 15, 45); showData(dataArray[0],dataArray[1],dataArray[2]); } } } else { text("server", 15, 45); text("stopped", 15, 65); } } void showData (int x,int y,int z) { text(x, 10, textLine); text(y, 60, textLine); text(z, 110, textLine); ellipse(100+ (x % 200), 100 + (y % 200), 12, 12); }
データ送信(コマンドライン)
サーバーはローカルホストで起動しているので、これにncコマンドで送ってみます
$ cat senddata.sh #!/bin/bash var=100 while : do var=`expr $var + 20` printf "%d,%d,111" $var 100 | netcat -c localhost 10002 sleep 1s done