CMU-CREATE-Lab / flutter-app-android

5 stars 3 forks source link

Blocks app using "set output" overwrites Links relationships #226

Open jenncross opened 7 years ago

jenncross commented 7 years ago

The Blocks app currently uses the SET OUTPUT ‘soutput,value' protocol command to send values to the Flutter.

When outputs are set using Blocks app, disconnected and reconnected to the Links app, the output relationship states are shown as either:

This should be examined further to determine causes for the different states. It might be the Blocks app is accidentally using call for a proportional link in certain cases e.g. "ps1,0,b4,1,0,64" or that somehow the Blocks app is triggering a bad state on the Flutter firmware. Perhaps in the way that relationships are removed?

One solution for the first type of "constant relationship" would be to create separate "Set Output" command (which does not save on the device memory ... for Blocks) and "Enable constant control" (which does save to memory ... for links).

@ehamner @lczito Please add your observations on this behavior.

jenncross commented 7 years ago

@bambibrewer I've added you here in order to confirm what commands are being send over Bluetooth to the Flutters by blocks.

bambibrewer commented 7 years ago

The commands for the flutter are:

TriLED (Say we want to send R: 100, G:100 B:100 to port 1). We send the following String as bytes:

"sl1,64,64,64" + (char) 0x0D

Servo (Say we want to send angle:100 to port 1). We send the following String as bytes:

"ss1,64"

Buzzer

For this, the fomat is:

"sz," + volumeByte + "," + 2 Bytes for frequency + "," + (char) 0x0D

So, if we want to send a volume of 100 and frequency of 20000, the command would be:

"sz,64,4e20" + (char) 0x0D

(Sent in the form of bytes)

All the above strings are converted into bytes based on ASCII, and then sent

NOTE: 0x0D is the return character 64 is the hex form of the decimal number 100

Does this shed any light on it? None of these look like your example, but I'm not sure what other commands Flutter Links is sending.


This is the relevant portion of the actual code:

/ Commands for Flutter / private static final String SET_CMD = "s"; private static final byte READ_CMD = 'r'; private static final String SERVO_OUTPUT = "s"; private static final String BUZZER_OUTPUT = "z"; private final static char CR = (char) 0x0D; private static final String SET_SERVO_CMD = SET_CMD + SERVO_OUTPUT + "%d,%x"; private static final String SET_BUZZER_CMD = SET_CMD + BUZZER_OUTPUT + ",%x,%x" + CR; private static final String SET_TRI_CMD = SET_CMD + "l" + "%d,%x,%x,%x" + CR;

/**

/**

/**

NOTE: conn.writeBytes() just sends the given byte array to the flutter as a stream of bytes

jenncross commented 6 years ago

We think that this might be fixed.

Need to confirm that it is fixed.

tasota commented 6 years ago

@jenncross and I were just revisiting this. It seems like the potential for a degraded state (which caused Flutter Links to crash originally) is no longer an issue.

However, the set output protocol command still overrides relationships since the command is really setting a Constant Relationship to the outputs. It sounds like this behavior will not be improved in the near future.