PDA

View Full Version : evaluate terminal/serial/rxtx/usb port ?


action_marc
09-30-2011, 08:16 PM
I am looking for any flash as2/as3 code
that can access mac (& win) terminal messages
(delivered by serial ports).
The message i need to receive via flash ...

- look like the following
"/DATA_RCVD_SIGN = 44/ DATA_RCVD = 1"

-are displayed on my mac's "terminal"
(or any other serial port terminal) program
and change at regular intervals (every minute)


------------------------------------
IDEALLY ...

the code would work like
ss6.jar ( am a newbee, not allowed to post the link -
pls. google "ss6.jar itp nyu edu" );

this applet allows to choose
- an active serial port,
- it's baude rate
&
to display incoming messages from this serial port


------------------------------------
I ALREADY HAD A LOOK AT ...

... Netlab toolkit, funnel. Tinkerit, arduino, related flash scripts
(using xmlsocket, serialServer , externalinterface and related )
but did not succeed in finding any solution yet.

I tried to read the output provided by ss6.jar
as well - but did not find a way to access them


------------------------------------
May you please send me any hint or link ?

Any help is greatly appreciated!

peptobismol
10-03-2011, 05:03 PM
you'd need a proxy app like java to send flash the information via the xmlSocket....
I guess both the proxy app and the flash has to be on a web server or turn your desktop into a web server.

action_marc
10-03-2011, 09:23 PM
thanks a lot for your reply, peptobismol!

will google "xmlSocket java" & send a post in case i succeed;

being an absolute beginner when it comes to java
my knowledge might be insufficient
since i tried to adapt/change several rxtx java scripts
without success already ...
( same with java based "websocket" solutions )

but it is definitely worth to give it a try -
thanks, again!

peptobismol
10-04-2011, 01:36 AM
Try using processing
http://processing.org/
It runs on JAVA and coding is a lot simpler. You can export as a jar.
Here's my code where I list all of the serial/usb ports. The user can choose which one the app listens to.

You would want to read/write to a socket not an io port. If you can NOT use flash in the mix, it would be best :)



import processing.serial.*;
import controlP5.*;

ControlP5 controlP5;
PFont font;
ListBox l;

Serial myPort; // Create object from Serial class
String value; // Data received from the serial port
String tempv;
public static final char CR = 13; // ASCII linefeed

void setup()
{
size(700, 700);
// I know that the first port in the serial list on my mac
// is always my FTDI adaptor, so I open Serial.list()[0].
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);

font = createFont("Arial", 200, true);
textFont(font);

///setup list
controlP5 = new ControlP5(this);
l = controlP5.addListBox("myList",5,20,200,120);
l.setItemHeight(15);
l.setBarHeight(15);

l.captionLabel().toUpperCase(true);
l.captionLabel().set("Serial/USB ports");
l.captionLabel().style().marginTop = 3;
l.valueLabel().style().marginTop = 3; // the +/- sign
//l.setBackgroundColor(color(100,0,0));
for(int i=0;i<Serial.list().length;i++) {
l.addItem(Serial.list()[i],i);
}
l.setColorBackground(color(255,128));
l.setColorActive(color(0,0,255,128));

value = "\n\r";
tempv = "\n\r";
}

void draw()
{
background(30,70,30);
if ( myPort.available() > 0) { // If data is available,
char val = char(myPort.read()); // read it and store it in val
if(val == CR) {
value = tempv;
tempv = "";
} else {
tempv += val;
}
}

textAlign(CENTER);
fill(200);
textSize(200);
text(value, 350, 100);

textAlign(LEFT);
fill(200);
textSize(10);
text("The default port is the first on the list. Choose another port if you know what you're doing.", 220, 9,150,500);



}


void controlEvent(ControlEvent theEvent) {
// ListBox is if type ControlGroup.
// 1 controlEvent will be executed, where the event
// originates from a ControlGroup. therefore
// you need to check the Event with
// if (theEvent.isGroup())
// to avoid an error message from controlP5.

if (theEvent.isGroup()) {
// an event from a group e.g. scrollList
int portIndex = (int) theEvent.group().value();
myPort = new Serial(this, Serial.list()[portIndex], 9600);

}
}

action_marc
10-04-2011, 09:02 AM
thanks a lot for your advice!
will have to try it - looks like an all-in-all handy solution
from the first look at it ...
even avoiding to use an additional serial port program
such as the ss6.jar i mentioned earlier
&
if it exports the .jar it would keep me from fiddling around
with "netbeans" etc.

thanks a lot, again!