Go to Post from time to time, we all need a good smack to make us see when we screwed up and did something we shouldn't have. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-03-2013, 08:01
evinugur evinugur is offline
Registered User
FRC #1073
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: US
Posts: 13
evinugur is an unknown quantity at this point
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

My code can be found here:
https://github.com/FRCTeam1073-TheFo.../netconsole.js
  #2   Spotlight this post!  
Unread 25-03-2013, 11:02
rbmj rbmj is offline
Registered User
FRC #0612 (Chantilly Robotics)
Team Role: Alumni
 
Join Date: Apr 2011
Rookie Year: 2011
Location: DC Area/Fairfax County
Posts: 192
rbmj is a jewel in the roughrbmj is a jewel in the roughrbmj is a jewel in the rough
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?
__________________
FRC 612 '12
USNA '16
  #3   Spotlight this post!  
Unread 25-03-2013, 11:15
evinugur evinugur is offline
Registered User
FRC #1073
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: US
Posts: 13
evinugur is an unknown quantity at this point
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.
  #4   Spotlight this post!  
Unread 25-03-2013, 22:35
gluxon's Avatar
gluxon gluxon is offline
\n
AKA: Brandon Cheng
FRC #0178 (The 2nd Law Enforcers)
Team Role: Leadership
 
Join Date: Apr 2012
Rookie Year: 2011
Location: Connecticut
Posts: 65
gluxon has a spectacular aura aboutgluxon has a spectacular aura aboutgluxon has a spectacular aura about
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.
  #5   Spotlight this post!  
Unread 26-03-2013, 07:22
evinugur evinugur is offline
Registered User
FRC #1073
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: US
Posts: 13
evinugur is an unknown quantity at this point
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!!!
  #6   Spotlight this post!  
Unread 26-03-2013, 15:24
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Difficulties in Sending UDP Data in a NetConsole Implementation

Quote:
Originally Posted by evinugur View Post
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? Unless I am mistaken, that is the reason its not working. If its not broadcast, NetConsoles ignores it.
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
  #7   Spotlight this post!  
Unread 26-03-2013, 17:33
gluxon's Avatar
gluxon gluxon is offline
\n
AKA: Brandon Cheng
FRC #0178 (The 2nd Law Enforcers)
Team Role: Leadership
 
Join Date: Apr 2012
Rookie Year: 2011
Location: Connecticut
Posts: 65
gluxon has a spectacular aura aboutgluxon has a spectacular aura aboutgluxon has a spectacular aura about
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

Last edited by gluxon : 26-03-2013 at 19:44.
  #8   Spotlight this post!  
Unread 26-03-2013, 19:48
evinugur evinugur is offline
Registered User
FRC #1073
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: US
Posts: 13
evinugur is an unknown quantity at this point
Re: Difficulties in Sending UDP Data in a NetConsole Implementation

Quote:
Originally Posted by gluxon View Post
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!
  #9   Spotlight this post!  
Unread 26-03-2013, 19:35
evinugur evinugur is offline
Registered User
FRC #1073
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: US
Posts: 13
evinugur is an unknown quantity at this point
Re: Difficulties in Sending UDP Data in a NetConsole Implementation

Quote:
Originally Posted by byteit101 View Post
Did you not think while typing that? 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.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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