async_port: fixed return error in SetupPort()

This commit is contained in:
Ruixiang Du
2021-09-02 16:51:31 +08:00
parent a63b25cc1f
commit af27fa2772
8 changed files with 43 additions and 33 deletions

View File

@@ -16,16 +16,19 @@ using namespace westonrobot;
int main(int argc, char **argv) {
ProtocolDectctor detector;
detector.Connect("can0");
if (detector.Connect("can0")) {
auto proto = detector.DetectProtocolVersion(5);
auto proto = detector.DetectProtocolVersion(5);
if (proto == ProtocolVersion::AGX_V1) {
std::cout << "Detected protocol: AGX_V1" << std::endl;
} else if (proto == ProtocolVersion::AGX_V2) {
std::cout << "Detected protocol: AGX_V2" << std::endl;
if (proto == ProtocolVersion::AGX_V1) {
std::cout << "Detected protocol: AGX_V1" << std::endl;
} else if (proto == ProtocolVersion::AGX_V2) {
std::cout << "Detected protocol: AGX_V2" << std::endl;
} else {
std::cout << "Detected protocol: UNKONWN" << std::endl;
}
} else {
std::cout << "Detected protocol: UNKONWN" << std::endl;
std::cout << "Failed to open port" << std::endl;
return -1;
}
return 0;