Open zfi opened 4 years ago
Received a report that appears to mirror this issue:
I started a TFMini project in Solo and immediately ran into that weird problem with the serial object -- where the name when used differs from what gets instantiated.
Thankfully, I was able to fix by setting the RX and TX pins to 0, compiling, setting them back, then compiling again.
It appears that the variable name fdser5_4 is getting truncated in the code generator for the calls to fdserialtxChar(). I suspect that the regex identified below is dropping characters after the ''.
Blockly.propc.serial_send_text = function () {
var p = '';
if (this.ser_pins.length > 0) {
p = this.ser_pins[0].replace(',', '_').replace(/None/g, 'N'); // <<=======
}
@MatzElectronics - can you take a look at this and post back what you find?
This is consistent with the bug I'm seeing.
On Wed, Jan 29, 2020, 11:17 AM Jim Ewald notifications@github.com wrote:
Received a report that appears to mirror this issue:
I started a TFMini project in Solo and immediately ran into that weird problem with the serial object -- where the name when used differs from what gets instantiated.
Thankfully, I was able to fix by setting the RX and TX pins to 0, compiling, setting them back, then compiling again.
[image: Screen Shot 2020-01-29 at 11 03 52 AM] https://user-images.githubusercontent.com/8442260/73388755-ae450b00-4287-11ea-8721-137b77e101af.png
It appears that the variable name fdser5_4 is getting truncated in the code generator for the calls to fdserialtxChar(). I suspect that the regex identified below is dropping characters after the ''.
Blockly.propc.serial_send_text = function () { var p = ''; if (this.ser_pins.length > 0) { p = this.serpins[0].replace(',', '').replace(/None/g, 'N'); // <<======= }
@MatzElectronics https://github.com/MatzElectronics - can you take a look at this and post back what you find?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/parallaxinc/solo/issues/246?email_source=notifications&email_token=AEWSVOFC2TPUBUQTIWGYAODRAHI3PA5CNFSM4KLJTTF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKIM2IQ#issuecomment-579915042, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWSVOA5PFZKDBPPPFDVNGDRAHI3PANCNFSM4KLJTTFQ .
Further testing, I'm seeing the following behavior:
Start with a serial init block in an empty "Other Board Type" project.
That will generate this code:
// ------ Libraries and Definitions ------
#include "simpletools.h"
#include "fdserial.h"
// ------ Global Variables and Objects ------
fdserial *fdser5_4;
// ------ Main Program ------
int main() {
fdser5_4 = fdserial_open(5, 4, 0b0000, 115200);
}
Add a Serial transmit block and the variable name gets truncated.
// ------ Libraries and Definitions ------
#include "simpletools.h"
#include "fdserial.h"
// ------ Global Variables and Objects ------
fdserial *fdser5_4;
// ------ Main Program ------
int main() {
fdser5_4 = fdserial_open(5, 4, 0b0000, 115200);
dprint(fdser5, "%s\r", 0);
while (!fdserial_txEmpty(fdser5));
pause(5);
}
Change the Serial transmit block by selecting decimal number from the drop-down and the variable is correct.
// ------ Libraries and Definitions ------
#include "simpletools.h"
#include "fdserial.h"
// ------ Global Variables and Objects ------
fdserial *fdser5_4;
// ------ Main Program ------
int main() {
fdser5_4 = fdserial_open(5, 4, 0b0000, 115200);
dprint(fdser5_4, "%d\r", 0);
}
I also tried this with just an init block and the Serial transmit block and could not reliably reproduce the error.
More data points...
Simply loading the sample project, Solo-246, the console generates a ton of errors that trace back to domToMutation in Blockly.Blocks.serial_print_multiple starting at line 1398:
if (serpin) {
this.appendDummyInput('SERPIN')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField('RXTX')
.appendField(new Blockly.FieldDropdown(this.ser_pins), 'SER_PIN'); // <<====
this.setFieldValue(serpin, 'SER_PIN');
if (this.getInput('PRINT0')) {
this.moveInputBefore('SERPIN', 'PRINT0');
}
}
Changes in PR #257 appear to correct the storm of errors noted above when the serial init block is dragged on the editor canvas. It also corrects the issue where the fdserial variable name was getting truncated at random times.
This issue persists and may be tested with code blocks from hee http://learn.parallax.com/tutorials/robot/activitybot/activitybot-360%C2%B0-and-pixy2-color-object-tracking
Thanks!
The serial pin assignments are retained correctly when loading this project from the Parallax Learn site. However, there is an error in the array blocks where the pixybuf variable is being replaced with the default list array variable. That issue is being tracked in Solo #447.
Originally reported in issue #195. Discovered with @kgracey that the serial init block is not properly saving it's pins - they reload in the blocks okay, but not for code generation. If you re-open a previously saved project, the compile will fail until you re-select the pins in the init block.