Skip to content

Instantly share code, notes, and snippets.

@ensonic
Created June 22, 2017 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ensonic/175818965c65cc9633033f851ea07d18 to your computer and use it in GitHub Desktop.
Save ensonic/175818965c65cc9633033f851ea07d18 to your computer and use it in GitHub Desktop.
From 7404c699ba0f33b5702d2dcba7e647ac92854567 Mon Sep 17 00:00:00 2001
From: Stefan Sauer <ensonic@users.sf.net>
Date: Thu, 22 Jun 2017 17:06:19 +0200
Subject: [PATCH] Compare with firmwareName instead of robotName.
RobotName is initialized from 'brickname' and can be changed on the robot (for the ev3 at least).
See #528
---
.../fhg/iais/roberta/robotCommunication/RobotCommunicationData.java | 5 +++++
.../de/fhg/iais/roberta/robotCommunication/RobotCommunicator.java | 6 ++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicationData.java b/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicationData.java
index d7a9114e1..141841d38 100644
--- a/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicationData.java
+++ b/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicationData.java
@@ -51,13 +51,18 @@ public class RobotCommunicationData {
String menuversion,
String firmwarename,
String firmwareversion) {
+ // the per session token
this.token = token;
+ // the robot group, such as 'ev3' ...
this.robot = robot;
this.robotIdentificator = robotIdentificator;
+ // the name of the robot, can be changed by the user in some cases
this.robotName = robotName;
this.battery = battery;
this.menuversion = menuversion;
+ // the robot variant, such as 'ev3dev' or 'lejos'
this.firmwarename = firmwarename;
+ // inbformal robot firmware version details
this.firmwareversion = firmwareversion;
this.sensorvalues = new JSONObject();
diff --git a/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicator.java b/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicator.java
index 4f2699830..d43321f2f 100644
--- a/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicator.java
+++ b/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicator.java
@@ -102,10 +102,8 @@ public class RobotCommunicator {
if ( state == null ) {
LOG.info("token " + token + " is not waiting for. Typing error of the user?");
return Key.TOKEN_SET_ERROR_NO_ROBOT_WAITING;
- } else if ( !(state.getRobot().equals(robot)
- || state.getRobotName().toLowerCase().equals(robot)
- || (state.getRobot() + state.getFirmwareName()).equals(robot)) ) {
- LOG.info("token " + token + " belongs to a robot of type " + state.getRobot() + ", client is set to " + robot);
+ } else if ( !(state.getRobot().equals(robot) || state.getFirmwareName().equals(robot) || (state.getRobot() + state.getFirmwareName()).equals(robot)) ) {
+ LOG.info("token " + token + " belongs to a robot of type " + state.getRobot() + "/" + state.getFirmwareName() + ", client is set to " + robot);
return Key.TOKEN_SET_ERROR_WRONG_ROBOTTYPE;
} else {
// todo: version check!
--
2.13.1.611.g7e3b11ae1-goog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment