Difficulties in Sending UDP Data in a NetConsole Implementation

I’m writing a program to emulate the features of NetConsole, and I’m having problems sending data down to the robot by means of the user entering a command into the terminal (i.e. ls)

I can read data fine just by listening to data on UDP Port 6666, and after doing some reading I found that the port for sending data is 6668 and I my program sends data to it via UDP.

My problem is that when I send down 6668, I get the same message on 6666, so the data sends, but the command doesn’t run on the robot.

For example, if I type “ls” and send it down to 6668, I essentially get ls echoed on 6666. My data is sending, but the behavior I want is to type “ls” and then stdout should print all of the files and directories on the robot.

I can read from stdout fine (for instance when the robot boots), so perhaps my command is being listened to not actually being processed on the robot?

I think the next test I’ll do is temporarily turn off the listening socket when I send a command, although that is a hacked approach…

My code is written in JavaScript for use with Node.js. The main point of this project was just so that I could run NetConsole in my tabbed Command Prompt such that I don’t have to open a new window just for console output :stuck_out_tongue:

My code can be found here:

Have you looked at any of the many re-implementations of NetConsole already in the wild?

Yes, actually. I used your Python implementation on GitHub as a reference for the port numbers.

The only big difference between our code is that you use the broadcast address and I use the robot’s address (10.TE.AM.2) for sending out data on 6668.

I suspect that this has something to do with our underlying datagram socket (python lib vs Node.js lib), as I am able to reach the listening socket.

I’ve been meaning to write a Node.js based NetConsole for a while, so I was delighted to this today. I’ll take a look at your code in more depth sometime tomorrow. Right now, I gotta study for some mean tests I missed due to a regional. :frowning:

Thanks for your reply, the more I use Node.js, the more I want more things to be supported with it :slight_smile:

I’m thinking of a few solutions right now… because the UDP data is reaching the listener but (apparently) not the robot perhaps just turn off the listening socket when I send down data… I can’t justify doing that though, it sounds like too much of a hack.

Thanks for eventually taking the time to read my code. I appreciate it!!!

Did you not think while typing that? :yikes: Unless I am mistaken, that is the reason its not working. If its not broadcast, NetConsoles ignores it.

Got it working. You need to end packets with "
". :slight_smile:

Edit: Here’s my working version if you want to look at it. Feel free to copy whatever you need. https://github.com/gluxon/NetConsole.js

I did try using the broadcast address… My listener will only intercept data coming from the team IP address.

Ahhh, thank you! I was pulling out hairs trying to figure this out and was getting superstitious enough to open datagram.js

I never would’ve though of the rollback character, but I completely forgot that the readline method takes the string up until enter is pressed…

I’ll add this in to the codebase, and update a finished version to npm. Thank you very much for your help!