Possible object model error
-
Good morning @droftarts,
I was writing a script to verify that my machines are running the correct firmware version, to ensure no mistakes are made. Occasionally, during assembly or when updating the firmware, some Duet components like the WiFi module, expansion boards, or PanelDue might not be mounted. Below is the macro I’ve written, but I’m encountering an issue: the line if boards[0].firmwareVersion == "3.5.3" works correctly, but if boards[1].firmwareVersion == "3.5.3" returns the following error:
M98 P"0:/macros/_MACROS DE FABRICA/0.-Verificación de firmware" Error: in file macro line 14 column 44: meta command: cannot convert operands to same type
Am I doing something wrong, or is this a different type of error?
if state.status == "processing" || state.status == "paused" M118 S{"Cannot be used during "^state.status} M99 if boards[0].firmwareVersion == "3.5.3" M291 R{boards[0].name} P{"The board is running the CORRECT firmware version. "^boards[0].firmwareVersion} S2 else M291 R{boards[0].name} P{"The board is NOT running the correct firmware version. "^boards[0].firmwareVersion} S2 M291 R{boards[0].name} P{"Firmware installation will proceed: "^boards[0].firmwareFileName} S3 M997 B0 S0 if exists(boards[1]) if boards[1].firmwareVersion == "3.5.3" M291 R{boards[1].name} P{"The board is running the CORRECT firmware version. "^boards[1].firmwareVersion} S2 else M291 R{boards[1].name} P{"The board is NOT running the correct firmware version. "^boards[1].firmwareVersion} S2 M291 R{boards[1].name} P{"Firmware installation will proceed: "^boards[1].firmwareFileName} S3 M997 B1 S0 else M291 R"ERROR" P"Duet3HC board not detected" S3 var counter = 10 if exists(network.interfaces[1]) if network.interfaces[1].state != "active" || network.interfaces[1].state != "idle" || network.interfaces[1].state == "disabled" M552 I1 S0 while true if network.interfaces[1].state == "idle" || var.counter <= 0 break else G4 P500 set var.counter = var.counter - 1 if network.interfaces[1].firmwareVersion == "2.1.0" || network.interfaces[1].state != "active" || network.interfaces[1].state != "idle" M291 R{"Module "^network.interfaces[1].type} P{"The "^network.interfaces[1].type^" module is running the CORRECT firmware version: "^network.interfaces[1].firmwareVersion} S2 else M291 R{"Module "^network.interfaces[1].type} P{"The "^network.interfaces[1].type^" module is NOT running the correct firmware version. "^network.interfaces[1].firmwareVersion} S2 M291 R{"Module "^network.interfaces[1].type} P{"Firmware installation will proceed for the "^network.interfaces[1].type^" module."} S3 M997 S1 else M291 R"ERROR" P"WiFi module not detected" S3 M291 R"PanelDue" P"Please ensure that the PanelDue is running version 3.5.0. Is it on that version?" S4 K{"YES","NO"} if input == 0 M291 R"PanelDue" P"You have confirmed that the PanelDue is running version 3.5.0." S2 else M291 R"PanelDue" P"Proceeding with PanelDue firmware installation." S3 M997 S4
Best regards,
-
@Aitor I just tried this, and get the same error. It seems that the boards[1].firmwareVersion is stored as the wrong data type, so can't be compared to the string (ie "3.5.3"). At least, I think that's what the error message is saying. One for @dc42 or @chrishamm to look at.
Ian
-
Good morning @droftarts,
Thank you for the quick response, I’ll wait then. One more question: is there any way to automatically check the version of the Panel Due, or do I have to do it manually?
Best regards,
-
@Aitor Sorry, I don't think there's any way of sending a message to the PanelDue, and retrieving the firmware version.
@chrishamm is investigating the OM issue.Ian
-
@Aitor @chrishamm reports that this is due to expansion boards being on the CAN bus, and CAN details are a different type code for the mainboard. The workaround is to use:
... if {boards[1].firmwareVersion ^ ""} == "3.5.3" ...
This may also affect these other OM fields related to expansion boards, ie firmwareDate, firmwareFileName, firmwareVersion, name and shortName.
I'll raise a Github issue for this.
Once it gets past that, I also got a number of these errors:
Warning: both space and tab characters used to indent blocks at/before line 38
Make sure your indentation is either tab or space, don't use both.
Ian
-
Good morning @droftarts,
Your solution worked correctly, but I don't quite understand why. You didn't really add anything by including ^"", did you? What would that be adding here?
Regarding spaces and tabs, I only use tabs, but something might have changed when translating or copying and pasting. My version of the code is in Spanish.
And as for the Panel Due, I was kind of expecting that, but I thought there might be something I didn’t know. It wouldn't be the first time .
Best regards,
-
@Aitor said in Possible object model error:
Your solution worked correctly, but I don't quite understand why. You didn't really add anything by including ^"", did you? What would that be adding here?
I'm sorry, but you'll have to ask @chrishamm why it works! I think it changes the data type to a string.
Ian
-
@droftarts said in Possible object model error:
I'm sorry, but you'll have to ask @chrishamm why it works! I think it changes the data type to a string.
ok