Serial Communication without terminal
timmsta
Posts: 6
Hi Everybody,
I'm trying to do an serial communication with the FullDuplexSerialPlus object and processing (java based programming tool -> processing.org). my problem is, that i can receive data from the propellor, but when sending, it's not understood by the prop. i guess it's a syntax problem, but i'm not exactly shure what the FullDuplexSerialPlus is expecting as e.g. an end signal. anybody got an idea, what i could try?
cheers
I'm trying to do an serial communication with the FullDuplexSerialPlus object and processing (java based programming tool -> processing.org). my problem is, that i can receive data from the propellor, but when sending, it's not understood by the prop. i guess it's a syntax problem, but i'm not exactly shure what the FullDuplexSerialPlus is expecting as e.g. an end signal. anybody got an idea, what i could try?
cheers
Comments
HTH,
--Rich
thanks or replying! I did check the baud rate and the hyperterminal, and it's all working nice with that. To just simply check the communication out, I made the code as simply as possible:
CON
_clkmode = xtal1 + pll16x ' System clock → 80 MHz
_xinfreq = 5_000_000
OBJ
Debug : "FullDuplexSerialPlus" ' Display object to use with HyperTerminal
PUB Init
'Configure ctra module.
ctra[noparse][[/noparse]30..26] := %00100 ' Set ctra for "NCO single-ended"
ctra[noparse][[/noparse]8..0] := 27 ' Set APIN to P27
frqa := 0 ' Don't send a tone yet.
dira[noparse][[/noparse]27]~~ ' I/O pin to output
dira[noparse][[/noparse]9] := 1
'Start FullDuplexSerialPlus.
Debug.start(31, 30, 0, 9600)
waitcnt(clkfreq * 2 + cnt)
SerialTest
PUB SerialTest | incomming
'dira[noparse][[/noparse]9] := 1
repeat
incomming := Debug.getDec
Debug.Str(String(10, 13, "I got: "))
Debug.Dec(incomming)
So it's simply just replying what it's getting. Exactly the same thing i'm doing with processing. as the FullDuplexSerialPlus is waiting for a signal, processing is just writing in a one second loop, and simply just prints out everything that comes in:
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
void setup()
{
size(200, 200);
String portName = Serial.list();
myPort = new Serial(this, portName, 9600);
println(Serial.list());
delay(1000);
}
void draw()
{
while (myPort.available() > 0) {
myPort.write(100);
myPort.write("13");
String inBuffer = myPort.readString();
if (inBuffer != null) {
println(inBuffer);
}
delay(1000);
}
}
(Don't now if this code helps you as it is kind of specific) As I said both codes are very rudamental, and things are working with the hyperterminal. I guess it's more on the processing side...
cheers
if i'm just looking if the port is open, like:
if (myPort.available() > 0){
println("gogogo!");
delay(10009;
}
it doesn't do anything at the first time. but, when getting impatient disconnect + connect again i just get just bad things from the chip like:
œ4m”¶h”œ<m”¶h”œ4m”¶h”œ4m”¶h”œ4m”–h”œ<m”–h”œ4m”–h”œ4m”–h”œ4m”–h”¶h”–h”œ4m ”–h”œÚ”–h”œÚ”–
but constantly - i have to reboot the chip in order to calm it down again...
any idea?
cheers
the forum can help if you attach your COMPLETE code to a posting.
best regards
Stefan
it's still the simple code i posted above. am trying things here and there but basicly it's still the same. and still i can read, but can't write. after while i would get this
" œ4m”¶h”œ<m”¶h”œ4m”¶h”œ4m”¶h”œ4m”–h”œ<m”–h”œ4m”–h”œ4m”–h”œ4m”–h”¶h”–h”œ4m ”–h”œÚ”–h”œÚ” "
so the complete code is above...
thx
I could solve it somehow, but still one bad thing is remaining. But First the solution (may be it might help sombody):
the problem was a confusion in the protocol between the FullDuplexSerialPlus and processing. I solved it like this:
void draw()
{
if ( myPort.available() > 0) {
val = myPort.readString(); //reading the serial port
String string = Integer.toString(number); //converting my integer to a string, because when processing is sending an int it wouldn't be understood
myPort.write(string); //sending the number as a string
myPort.write(0); //sending 0 as FullDuplexSerialPlus expects it as a termination signal (didn't look up why it works here as an int)
myPort.write('A'); //instead of the "enter"-Signal is use a capital A as Character, otherwise things didn`t work
delay(100);
number++;
}
loop();
}
But still one thing remains: if i disconnect and connect again the propellor keeps sending lots of confusing signs (mentioned above). Does anybody know whats there wrong?
cheers