Serial buffer or faster processing?
hello,
i developing hardware interface controlled through serial port. system made of switches , leds. led driver max7219 ledcontrol library. have speed issues in processing commands sent on com port. can send command : "lxyz=status:" where
l : tells arduino i'm going manage led
x : device id (number of max7219 i'm going operate)
y : led row
z : led column
status : "1" turning on or "0" turning off led
":" : separation character
the following code works if drive few leds per time, when longer strings (i.e. processing 64 leds: -> "l000=1:l001=1:.........:l076=1:l077=1") first ones processed , rest of commands gets lost.
i have been trying lowering serial speed 19.200 , more leds processed. tried increase buffer size 256kb , more leds processed). if test arduino due works native serial port (i know buffer 512kb there) think there should way optimize code don't have use arduino due such simple job, uses 5 pins on board.
my question : code taking serial stream 1 character per time, processing, reading next one. if processing takes long reading takes long. possible stream whole serial buffer 1 or more strings , parse strings after? have advice on how so?
i hope explained well.
thanks in advance help,
best regards.
i developing hardware interface controlled through serial port. system made of switches , leds. led driver max7219 ledcontrol library. have speed issues in processing commands sent on com port. can send command : "lxyz=status:" where
l : tells arduino i'm going manage led
x : device id (number of max7219 i'm going operate)
y : led row
z : led column
status : "1" turning on or "0" turning off led
":" : separation character
the following code works if drive few leds per time, when longer strings (i.e. processing 64 leds: -> "l000=1:l001=1:.........:l076=1:l077=1") first ones processed , rest of commands gets lost.
code: [select]
if (serialusb.available() > 0) {
char1 = serialusb.read();
if (char1 == 'l'){ // codice "l" indica che voglio abilitare il led
delay (11);
// leggo 4 caratteri (1 numero board, 2 numero riga, 3 numero colonna, 1 per indicare lo stato 0 o 1 per spento/acceso
lednumber = "";
lednumber += char(serialusb.read());
lednumber += char(serialusb.read());
lednumber += char(serialusb.read());
serialusb.read(); // legge il carattere '='
lednumber += char(serialusb.read());
serialusb.read(); // legge il carattere ':'
boardindex = lednumber.charat(0) - '0';
row = lednumber.charat(1) - '0';
column = lednumber.charat(2) - '0';
if ((lednumber.charat(3) - '0') == 1) {
ledstatus = true;
}
else {
ledstatus = false;
}
if (boardindex<devices) {
lc.setled(boardindex, row, column, ledstatus);
}
}
}
i have been trying lowering serial speed 19.200 , more leds processed. tried increase buffer size 256kb , more leds processed). if test arduino due works native serial port (i know buffer 512kb there) think there should way optimize code don't have use arduino due such simple job, uses 5 pins on board.
my question : code taking serial stream 1 character per time, processing, reading next one. if processing takes long reading takes long. possible stream whole serial buffer 1 or more strings , parse strings after? have advice on how so?
i hope explained well.
thanks in advance help,
best regards.
Arduino Forum > Using Arduino > Programming Questions > Serial buffer or faster processing?
arduino
Comments
Post a Comment