I'm writing an interactive Processing sketch to control a laser projector by sending messages over UDP to the Ether Dream DAC. I have successfully compiled and run the C driver provided by the Ether Dream creator, and studied the protocol described here: http://ether-dream.com/protocol.html
I am using the UDP library for Processing, and have successfully read the status signal that the DAC broadcasts every second. I can seemingly send messages (described in the DAC protocol) to the DAC using the udp.send() but I never get the acknowledgement message back.
udp =new UDP(this,7654);
When I initialize my UDP object this way I am able to read the broadcast message.
but...
udp =new UDP(this,7654,"192.169.0.101");
When I initialize it this way I get the message:
opening socket failed!
> address:192.169.0.101, port:7654[group:null]
>Can't assign requested addressI have also tried port 7765, which is also mentioned in the documentation but with the same result.
The UDP library opens a connection like this:
// open a new socket to the specified port/address
// and join the group if the multicast socket is required
try{
InetAddress addr =InetAddress.getByName(ip);
InetAddress host =(ip==null)?(InetAddress)null: addr;
if(!addr.isMulticastAddress()){
ucSocket =newDatagramSocket( port, host );// as broadcast
log("bound socket to host:"+address()+", port: "+port());
}
The C driver provided by the Ether Dream creator which runs successfully opens a connection to the DAC like this:
struct etherdream_conn *conn =&d->conn;
memset(conn,0,sizeof*conn);
// Open socket
conn->dc_sock = socket(AF_INET, SOCK_STREAM,0);
if(conn->dc_sock <0){
log_socket_error(d,"socket");
return-1;
}
unsignedlong nonblocking =1;
ioctl(conn->dc_sock, FIONBIO,&nonblocking);
struct sockaddr_in addr ={
.sin_family = AF_INET,
.sin_addr.s_addr = d->addr.s_addr,.sin_port = htons(7765)
};
// Because the socket is nonblocking, this will always error...
connect(conn->dc_sock,(struct sockaddr *)&addr,(int)sizeof addr);
if(errno != EINPROGRESS){
log_socket_error(d,"connect");
goto bail;
}
The repository for this driver can be found here.
Why can't I establish a connection to the DAC through the Processing UDP library? How can I modify the Java implementation of the UDP library so that it matches the C driver which can successfully connect to the DAC? I'm relatively comfortable programming in Java/C/Processing but don't have any experience with network programming. Some help would be much appreciated!