TelluIoT / ThingML

The ThingML modelling language
https://github.com/TelluIoT/ThingML
Apache License 2.0
102 stars 32 forks source link

error statement in Arduino compiler #19

Closed brice-morin closed 12 years ago

brice-morin commented 12 years ago

The error statement (the equivalent of System.err.print in Java) is: 1/ not supported in the Arduino compiler (which is not so problematic), and 2/ potentially leads to compilation errors in the resulting code (which is blocking)

For example, the following ThingML code: if (index == MAX_PACKET_SIZE) do error("BUFFER OVERFLOW: " + b + " has been ignored. Current index = " + index) end

compiles to: if(_instance->PacketManager_index_var == _instance->PacketManager_MAX_PACKET_SIZE_var) { // ERROR: ("BUFFER OVERFLOW: " + b + " has been ignored. Current index = " + _instance->PacketManager_index_var)}

There should be a \n at the end of the ERROR statement so that the if statement could properly be closed (the closing brace is commented in the generated code

ffleurey commented 12 years ago

The compilation problem should now be fixed.

The reason why it is not supported is that we do not really have an output device to print to on the arduino since using the serial port is not always an option. Maybe we should have annotations which allow generating prints on the serial port or maybe on an LCD screen in some cases.