mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-13 10:29:35 +01:00
Detect version of bridge.py running on the Yun.
This commit is contained in:
parent
d5c828736b
commit
bc584744f6
@ -57,9 +57,9 @@ void BridgeClass::begin() {
|
||||
|
||||
// Reset the brigde to check if it is running
|
||||
uint8_t cmd[] = {'X', 'X', '1', '0', '0'};
|
||||
uint8_t res[1];
|
||||
uint8_t res[4];
|
||||
max_retries = 50;
|
||||
uint16_t l = transfer(cmd, 5, res, 1);
|
||||
uint16_t l = transfer(cmd, 5, res, 4);
|
||||
if (l == TRANSFER_TIMEOUT) {
|
||||
// Bridge didn't start...
|
||||
// Maybe the board is starting-up?
|
||||
@ -71,6 +71,14 @@ void BridgeClass::begin() {
|
||||
if (res[0] != 0)
|
||||
while (true);
|
||||
|
||||
// Detect bridge version
|
||||
if (l == 4) {
|
||||
bridgeVersion = (res[1]-'0')*100 + (res[2]-'0')*10 + (res[3]-'0');
|
||||
} else {
|
||||
// Bridge v1.0.0 didn't send any version info
|
||||
bridgeVersion = 100;
|
||||
}
|
||||
|
||||
max_retries = 50;
|
||||
return;
|
||||
}
|
||||
|
@ -61,12 +61,18 @@ class BridgeClass {
|
||||
return transfer(buff1, len1, buff2, len2, NULL, 0, rxbuff, rxlen);
|
||||
}
|
||||
|
||||
uint16_t getBridgeVersion()
|
||||
{
|
||||
return bridgeVersion;
|
||||
}
|
||||
|
||||
static const int TRANSFER_TIMEOUT = 0xFFFF;
|
||||
|
||||
private:
|
||||
uint8_t index;
|
||||
int timedRead(unsigned int timeout);
|
||||
void dropAll();
|
||||
uint16_t bridgeVersion;
|
||||
|
||||
private:
|
||||
void crcUpdate(uint8_t c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user