Skip to content

Commit bc58474

Browse files
committed
Detect version of bridge.py running on the Yun.
1 parent d5c8287 commit bc58474

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

libraries/Bridge/src/Bridge.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ void BridgeClass::begin() {
5757

5858
// Reset the brigde to check if it is running
5959
uint8_t cmd[] = {'X', 'X', '1', '0', '0'};
60-
uint8_t res[1];
60+
uint8_t res[4];
6161
max_retries = 50;
62-
uint16_t l = transfer(cmd, 5, res, 1);
62+
uint16_t l = transfer(cmd, 5, res, 4);
6363
if (l == TRANSFER_TIMEOUT) {
6464
// Bridge didn't start...
6565
// Maybe the board is starting-up?
@@ -71,6 +71,14 @@ void BridgeClass::begin() {
7171
if (res[0] != 0)
7272
while (true);
7373

74+
// Detect bridge version
75+
if (l == 4) {
76+
bridgeVersion = (res[1]-'0')*100 + (res[2]-'0')*10 + (res[3]-'0');
77+
} else {
78+
// Bridge v1.0.0 didn't send any version info
79+
bridgeVersion = 100;
80+
}
81+
7482
max_retries = 50;
7583
return;
7684
}

libraries/Bridge/src/Bridge.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,18 @@ class BridgeClass {
6161
return transfer(buff1, len1, buff2, len2, NULL, 0, rxbuff, rxlen);
6262
}
6363

64+
uint16_t getBridgeVersion()
65+
{
66+
return bridgeVersion;
67+
}
68+
6469
static const int TRANSFER_TIMEOUT = 0xFFFF;
6570

6671
private:
6772
uint8_t index;
6873
int timedRead(unsigned int timeout);
6974
void dropAll();
75+
uint16_t bridgeVersion;
7076

7177
private:
7278
void crcUpdate(uint8_t c);

0 commit comments

Comments
 (0)