Go to Post this thread made crave bacon so badly that I am now, as I write this, cooking 2 pounds of it. :o - gvarndell [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-03-2011, 11:42
Daniel Daniel is offline
Daniel Katanski
#0240
Team Role: Mentor
 
Join Date: Feb 2004
Location: Monroe, MI
Posts: 32
Daniel is on a distinguished road
Need help opening a socket to send data to Classmate running putty.

Attention coding wizards:

My goal is to send diagnostic text to the Classmate to be displayed using putty as a custom/flexible diagnostic display. Here is my code:


import javax.microedition.io.SocketConnection;
import javax.microedition.io.Connector;
import java.io.OutputStream;
import java.io.IOException;


private SocketConnection socket ; // Socket to Classmate
private OutputStream outputStream;


try {
socket = (SocketConnection) Connector.open("telnet://10.36.38.6:23");
socket.setSocketOption(SocketConnection.LINGER, 5);

outputStream = socket.openOutputStream();

System.out.println("Diagnostic socket open.\r\n");

outputStream.write("Goodbye World!\r\n".getBytes());

outputStream.close();

} catch (IOException e) {
System.out.println("Error opening diagnostic socket: " + e.getMessage() + "\r\n");
}


This code gets an error stating "Telnet protocol is not available" (or something similar).

I will try another socket number tonight.

But does anyone have any suggestions how to open a socket or stream to send that to the classmate.

Dan
Reply With Quote
  #2   Spotlight this post!  
Unread 03-03-2011, 13:48
Daniel Daniel is offline
Daniel Katanski
#0240
Team Role: Mentor
 
Join Date: Feb 2004
Location: Monroe, MI
Posts: 32
Daniel is on a distinguished road
Re: Need help opening a socket to send data to Classmate running putty.

According to Team Update #5 there are 5 ports available: TCP 1180, UDP 1130, UDP 1140, HTTP 80 and HTTP 443.

FIRST must have disabled all other ports.
Reply With Quote
  #3   Spotlight this post!  
Unread 03-03-2011, 14:12
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 357
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
Re: Need help opening a socket to send data to Classmate running putty.

I don't think Putty can be set to listen on a port as a telnet server. Correct me if I'm wrong. Usually putty is used as a client to connect to a listening "server'. You may need to call 'listen' (specifying an availabe port) and 'accept' in your CRIO code and then Putty on the classmate can connect to it. Exaclty how to do that in java is beyond what I can look up right now.
__________________
Brian K
Team 1225 Robotics Mentor
Reply With Quote
  #4   Spotlight this post!  
Unread 03-03-2011, 19:14
spartango spartango is offline
Registered User
FRC #0192 (GRT)
Team Role: Alumni
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Palo Alto, CA
Posts: 43
spartango is an unknown quantity at this point
Re: Need help opening a socket to send data to Classmate running putty.

I'll leave this here:
http://code.google.com/p/grtframewor...2Fn etworking

you should find examples for what you're looking for, as well as other networking setups. This code has been tested, so you should be good to go.
Reply With Quote
  #5   Spotlight this post!  
Unread 04-03-2011, 09:55
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: Need help opening a socket to send data to Classmate running putty.

You need to use the "socket:" or "serversocket:" protocols instead of "telnet:" when you create your connection. And definitely check out spartango's example code.
Reply With Quote
  #6   Spotlight this post!  
Unread 04-03-2011, 11:46
Daniel Daniel is offline
Daniel Katanski
#0240
Team Role: Mentor
 
Join Date: Feb 2004
Location: Monroe, MI
Posts: 32
Daniel is on a distinguished road
Re: Need help opening a socket to send data to Classmate running putty.

I tryied spartango's link, but got page not found.

Spartango, can you please paste the code into this thread or create an attachment?
Reply With Quote
  #7   Spotlight this post!  
Unread 04-03-2011, 15:04
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: Need help opening a socket to send data to Classmate running putty.

You can find more information and example code on networking and file i/o in these articles:

http://developers.sun.com/mobility/midp/articles/genericframework/
http://developers.sun.com/mobility/midp/articles/midp2network/
Reply With Quote
  #8   Spotlight this post!  
Unread 09-03-2011, 12:21
Daniel Daniel is offline
Daniel Katanski
#0240
Team Role: Mentor
 
Join Date: Feb 2004
Location: Monroe, MI
Posts: 32
Daniel is on a distinguished road
Re: Need help opening a socket to send data to Classmate running putty.

spartango and derek, I've tried to test this sample but can not find definitions for the SocketListener and SocketEvent objects.

Has this code every been tested/run in our FIRST configuration?

I would still like to get this working. As a interm fix I am getting a Serial RS232 to USB converter and will use putty listening to COM1.
Reply With Quote
  #9   Spotlight this post!  
Unread 10-03-2011, 08:41
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: Need help opening a socket to send data to Classmate running putty.

Hi, those classes are also in spartango's code:

http://code.google.com/p/grtframewor...tListener.java
http://code.google.com/p/grtframewor...cketEvent.java
Reply With Quote
Reply


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