Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Difficulties in Sending UDP Data in a NetConsole Implementation (http://www.chiefdelphi.com/forums/showthread.php?t=115397)

evinugur 25-03-2013 08:01

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 :P

My code can be found here:
https://github.com/FRCTeam1073-TheFo.../netconsole.js

rbmj 25-03-2013 11:02

Re: Difficulties in Sending UDP Data in a NetConsole Implementation
 
Have you looked at any of the many re-implementations of NetConsole already in the wild?

evinugur 25-03-2013 11:15

Re: Difficulties in Sending UDP Data in a NetConsole Implementation
 
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.

gluxon 25-03-2013 22:35

Re: Difficulties in Sending UDP Data in a NetConsole Implementation
 
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. :(

evinugur 26-03-2013 07:22

Re: Difficulties in Sending UDP Data in a NetConsole Implementation
 
Thanks for your reply, the more I use Node.js, the more I want more things to be supported with it :)

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!!!

byteit101 26-03-2013 15:24

Re: Difficulties in Sending UDP Data in a NetConsole Implementation
 
Quote:

Originally Posted by evinugur (Post 1252349)
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.

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.

gluxon 26-03-2013 17:33

Re: Difficulties in Sending UDP Data in a NetConsole Implementation
 
Got it working. You need to end packets with "\r\n". :)

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

evinugur 26-03-2013 19:35

Re: Difficulties in Sending UDP Data in a NetConsole Implementation
 
Quote:

Originally Posted by byteit101 (Post 1253041)
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.

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

evinugur 26-03-2013 19:48

Re: Difficulties in Sending UDP Data in a NetConsole Implementation
 
Quote:

Originally Posted by gluxon (Post 1253099)
Got it working. You need to end packets with "\r\n". :)

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!


All times are GMT -5. The time now is 03:09.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi