Hello XPort

Photo_021906_001.jpg

This program in Processing simply opens a connection to an XPort, on its default port. We just tried it and it works. The next step will be to add a function that reads a byte of data, sent from the PIC.

// rob@faludi.com
// This program receives information from an XPort PIC board it may also send
import java.io.*;
import java.net.*;

String host;
int port;
Socket s; // create a socket for output

void setup () {
size(200,200);
host = “xport3.faludi.com”;
port = 10001;
connectXPort();
}

void draw () {
if (s.isConnected()==false) {
connectXPort();
}
}

// connect to the XPort
void connectXPort () {
try { // processes that might fail have to get wrapped in a try loop
s = new Socket(host, port); // open that socket to the server
println(“connected”);
}
catch (Exception e) {
e.printStackTrace();
println(“Unable to open connection to: “+host+” at port:”+port);
}
}

Scroll to Top