1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-29 18:52:13 +01:00

Bridge: fix transfers which ignored host response

Bridge.put() was broken by #2781 because it used transfer() 2-parameters overloaded version, which imply that rxlen == 0.
But the Linux Bridge responded, so the check (i >= rxlen) was true and the function timed out after retrying 50 times.

Every bridge command (python side) has been checked and now SHOULD strictly follow this rule and never ignore silently the received data
This commit is contained in:
Martino Facchin 2015-03-30 15:37:06 +02:00
parent 3788128385
commit 45ff4f60b3
2 changed files with 4 additions and 2 deletions

View File

@ -87,10 +87,11 @@ void BridgeClass::begin() {
void BridgeClass::put(const char *key, const char *value) {
// TODO: do it in a more efficient way
String cmd = "D";
uint8_t res[1];
cmd += key;
cmd += "\xFE";
cmd += value;
transfer((uint8_t*)cmd.c_str(), cmd.length());
transfer((uint8_t*)cmd.c_str(), cmd.length(), res, 1);
}
unsigned int BridgeClass::get(const char *key, uint8_t *value, unsigned int maxlen) {

View File

@ -175,7 +175,8 @@ void File::close() {
if (mode == 255)
return;
uint8_t cmd[] = {'f', handle};
bridge.transfer(cmd, 2);
uint8_t ret[1];
bridge.transfer(cmd, 2, ret, 1);
mode = 255;
}