I'm trying to create a "UDP serial console" for my Arduino Due + CC3000. I currently have a TCP based version that works well, except I don't like having to reconnect my telnet session every time I power cycle/reprogram my Arduino.
I've been working on getting a UDP based version, but have run into several issues I'm hoping someone has some ideas on.
1) I can't see UDP sendto traffic on wireshark.
My linux laptop (192.168.1.100) is running wireshark and recording traffic. I created a simple Stream class that calls "sendto" each time a Stream::write call happens. Return values are coming back as success from the sendto call.. have checked and recheck arguments... can't find what I'm missing.
Source is located at:
https://github.com/jrjbertram/robotomy/ ... dpStream.h
https://github.com/jrjbertram/robotomy/ ... Stream.cpp
Relevant code snippet:
Code: Select all
size_t UdpStream::write( uint8_t data)
{
Serial.println( "write: entry" );
sockaddr_in address;
memset(&address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_port = htons(_port);
// JRB: Need to figure out how to set this to broadcast, or maybe a multicast address
address.sin_addr.s_addr = 0xE1000025; // multicast 225.0.0.37
//address.sin_addr.s_addr = 0xC0A80164; // 192.168.1.100, laptop addr
socklen_t len = sizeof(address);
Serial.println( "calling sendto" );
int n = sendto(_socket, &data, 1, 0, (sockaddr*)&address, len);
Serial.print( "sendto returned " );
Serial.println( n ); // returns 1
// snip
Interestingly, I tried tweaking one of the UDP-based NTP examples, but did not see any UDP traffic (even though it seemed to work). Not 100% sure I modified that example correctly, so ... hrmm.
Anyone know if this is normal? I'm also sniffing on the wireless lan interface.. not sure if that makes a difference.
2) I can't find a good example of how to use broadcast address or multicast address.
In the sendto snippet above, I've attempted to set to my broadcast address on my local network (192.168.1.255) and tried a random multicast address (225.0.0.37). Didn't see either on the wireshark trace.
3) Is anyone aware of a good / simple UDP client example? There seems to be lots of discussion of a UDP server, but I didn't see much in the way of client discussion. I'm aware that the NTP clients are UDP-based, they just have a lot of complexity. Looking for something simple.
Goal eventually here will be to power up the board, have a python script monitor on a broadcast or multicast address... this will allow me hopefully to untether from USB but still provide me a simple way to pass in commands and peek/poke at status of my project wirelessly. Might also try to hook up to something that already works, such as http://www.cinetix.de/interface/tiptrix/udpterm.htm
Thanks in advance,
- Josh.