Problem with 3 Serial Ports on UNO
hi all,
i wrote wrapper aprs modem/bertos firmware ( http://unsigned.io/microaprs/ ) ...
the arduino wrapper located @ https://github.com/stanleyseow/arduinotracker-microaprs
i wanted write similar radio shield 2 https://www.argentdata.com/catalog/product_info.php?products_id=136 open source ...
i needed 3 serial port following functions :-
pin 0,1 ( 9600) - connect aprs modem send commands , received decoded aprs packets radio
pin 2,3 (9600) - connect gps module gps coordinates ( softwareserial )
pin 8,9 (57600) - connect ftdi serial usb module debugging , send in commands purposes...
- pin 8,9 using altsoftserial http://www.pjrc.com/teensy/td_libs_altsoftserial.html
things not working (yet) :-
- not copied entire decoded aprs packet string or char array
i want display callsign ( string after src: ) , data: on 20x4 lcd not grab entire row or partial of sample string below..
i suspect there many calls other serial port ( e.g. gps on software serial or debug ) , therefore blocking this..
how shall solve serial port issue 3 serial ports running @ same time...
thanks
stanley
the output of decoded messages aprs modem below :-
the decodeaprs functions, entire source codes @ github url stated above ...
i wrote wrapper aprs modem/bertos firmware ( http://unsigned.io/microaprs/ ) ...
the arduino wrapper located @ https://github.com/stanleyseow/arduinotracker-microaprs
i wanted write similar radio shield 2 https://www.argentdata.com/catalog/product_info.php?products_id=136 open source ...
i needed 3 serial port following functions :-
pin 0,1 ( 9600) - connect aprs modem send commands , received decoded aprs packets radio
pin 2,3 (9600) - connect gps module gps coordinates ( softwareserial )
pin 8,9 (57600) - connect ftdi serial usb module debugging , send in commands purposes...
- pin 8,9 using altsoftserial http://www.pjrc.com/teensy/td_libs_altsoftserial.html
things not working (yet) :-
- not copied entire decoded aprs packet string or char array
i want display callsign ( string after src: ) , data: on 20x4 lcd not grab entire row or partial of sample string below..
i suspect there many calls other serial port ( e.g. gps on software serial or debug ) , therefore blocking this..
how shall solve serial port issue 3 serial ports running @ same time...
thanks
stanley
the output of decoded messages aprs modem below :-
code: [select]
src: [9w2bbb-12] path: [9m2kkk-3] [wide1-1] [wide2-2] data: !/lq@yh1usp?dg/a=000273 13.6v 32caprs
src: [9m2ccc-3] path: [wide2-1] data: !/lqluh1'q# st 11.8v 33c maaas vhf 144.3900mhz
src: [9w2aaa-0] path: [9m4rrr-3] [9m2ttt-1] [9m2kkk-3] [wide1-0] data: @050418z0300.35n/000004.61ez
src: [9m2kkk-3] path: [wide2-1] data: !/lqluh1'q# st 11.8v 33c maaas vhf 144.3900mhz
the decodeaprs functions, entire source codes @ github url stated above ...
code: [select]
void decodeaprs() {
char c;
char endchar = '\n';
char endchar2 = '\r';
boolean storestring = true;
char callsign[12];
char path[60];
char data[100];
debug.println();
debug.print("entering decodeaprs (");
debug.print(millis());
debug.println(")");
while ( serial.available() > 0 ) {
c = serial.read();
// debugging
debug.print(c);
// if maxbuffer reach, null terminate string
if ( bufferindex > maxbuffer ) {
charbuffer[maxbuffer] = 0;
storestring = false;
}
// check endchar , null terminate string
if ( c == endchar || c == endchar2 ) {
charbuffer[bufferindex] = 0;
storestring = false;
}
if ( storestring ) {
charbuffer[bufferindex++] = c;
}
}
// save buffers strings if charbuffer not blank
if ( !storestring && (!charbuffer[0] == 0) ) {
inbuffer = charbuffer;
}
if ( inbuffer != "" && !storestring ) {
debug.println();
debug.print("rf(");
debug.print(inbuffer.length());
debug.print("):");
debug.println(inbuffer);
// check first 3 char src
if ( inbuffer.substring(0,3) == "src" ) {
int firstbracket = inbuffer.indexof('['); // in between [ , ] callsign & ssid
int secondbracket = inbuffer.indexof(']');
//int secondcolon = inbuffer.indexof(':',secondbracket+1);
int secondcolon = secondbracket+6;
// not use lastindexof messaging uses :
int thirdcolon = inbuffer.indexof(':',secondcolon+1);
// callsign
string decoded2 = inbuffer.substring(firstbracket+1,secondbracket); // substring callsign
decoded2.tochararray(callsign,secondbracket+1-firstbracket-1); // convert char array
// path
string decoded3 = inbuffer.substring(secondcolon+2,thirdcolon-5);
decoded3.tochararray(path,decoded3.length()+1);
// data
string decoded4 = inbuffer.substring(thirdcolon+2,inbuffer.length());
decoded4.tochararray(data,decoded4.length()+1);
debug.print("callsign (");
debug.print(strlen(callsign));
debug.print("):");
debug.println(callsign);
debug.print("path (");
debug.print(strlen(path));
debug.print("):");
debug.println(path);
debug.print("data (");
debug.print(strlen(data));
debug.print("):");
debug.println(data);
lcd.clear();
lcd.setcursor(0,0);
lcd.print(callsign);
lcd.setcursor(0,1);
lcd.print(" ");
lcd.setcursor(0,1);
( int i=0;i<20;i++ ) { lcd.print(data[i]); }
// print on line 2
lcd.setcursor(0,2);
lcd.print(" ");
lcd.setcursor(0,2);
if ( strlen(data) < 40 ) {
( int i=20;i<strlen(data);i++ ) { lcd.print(data[i]); }
} else {
( int i=20;i<40;i++ ) { lcd.print(data[i]); } // truncate data till 40 bytes
}
firstbracket, secondbracket, secondcolon, thirdcolon = 0;
} // endif src check
// clear buffers after saving out variables callsign, path , data
inbuffer = ""; // clear buffers
charbuffer[0] = 0; // clear buffers
bufferindex = 0; // reset index
callsign[0] = 0;
path[0] = 0;
data[0] = 0;
} // end storestring
}
i not understand wrote, doubt if combining both softwareserial , altsoftserial work.
do use libraries use same timer altsoftserial ?
normally softwareserial can used few serial ports. select 1 port , sent , wait respose. after select serial port , on. think okay gps module, don't know how modem behaves.
the arduino leonardo has same size arduino uno, , leonardo might able this. when use usb connection debugging , commands (and upload sketch), , use hardware serial @ pin 0 , 1 modem, , softwareserial library gps.
the leonardo uses internal software/hardware serial port usb, , hardware serial port @ pin 0 , 1 free available own use.
the arduino mega 2560 has 4 hardware serial ports.
do use libraries use same timer altsoftserial ?
normally softwareserial can used few serial ports. select 1 port , sent , wait respose. after select serial port , on. think okay gps module, don't know how modem behaves.
the arduino leonardo has same size arduino uno, , leonardo might able this. when use usb connection debugging , commands (and upload sketch), , use hardware serial @ pin 0 , 1 modem, , softwareserial library gps.
the leonardo uses internal software/hardware serial port usb, , hardware serial port @ pin 0 , 1 free available own use.
the arduino mega 2560 has 4 hardware serial ports.
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Problem with 3 Serial Ports on UNO
arduino
Comments
Post a Comment