Error while compiling python code for Node MCU


#1

Hi,

When I try to Verify my code prior to deploying it to my Node MCU v2 I get this error, which I have absolutely no idea what to make of - I hope someone can help. I’ve uploaded the code after the error messages if you want to see it as well a few lines to give you some context.

I’m somewhat of a noob, so I have spend quite a bit of time building this. I would be sorry to see my work go down the drain because I cant make out what the erros mean. Any help would be greatly appreciated.

[fatal] Unexpected exception

Traceback (most recent call last):

File “C:\Users\Singularity zero\zerynth2\dist\r2.3.2\ztc\compiler\compilercmd.py”, line 80, in _zcompile

binary, reprs = compiler.compile()

File “C:\Users\Singularity zero\zerynth2\dist\r2.3.2\ztc\compiler\compiler.py”, line 505, in compile

self.compileModule(self.mainfile)

File “C:\Users\Singularity zero\zerynth2\dist\r2.3.2\ztc\compiler\compiler.py”, line 470, in compileModule

mc.visit(tree)

File “C:\Users\Singularity zero\zerynth2\sys\python\lib\ast.py”, line 245, in visit

return visitor(node)

File “C:\Users\Singularity zero\zerynth2\dist\r2.3.2\ztc\compiler\astwalker.py”, line 103, in visit_Module

self.code.addCode(self.visit(stmt))

File “C:\Users\Singularity zero\zerynth2\sys\python\lib\ast.py”, line 245, in visit

return visitor(node)

File “C:\Users\Singularity zero\zerynth2\dist\r2.3.2\ztc\compiler\astwalker.py”, line 638, in visit_While

code.addCode(self.genCodeList(node.body))

File “C:\Users\Singularity zero\zerynth2\dist\r2.3.2\ztc\compiler\astwalker.py”, line 92, in genCodeList

listcode.append(self.visit(cc))

File “C:\Users\Singularity zero\zerynth2\sys\python\lib\ast.py”, line 245, in visit

return visitor(node)

File “C:\Users\Singularity zero\zerynth2\dist\r2.3.2\ztc\compiler\astwalker.py”, line 516, in visit_Assign

valuecode = self.visit(node.value)

File “C:\Users\Singularity zero\zerynth2\sys\python\lib\ast.py”, line 245, in visit

return visitor(node)

File “C:\Users\Singularity zero\zerynth2\dist\r2.3.2\ztc\compiler\astwalker.py”, line 267, in visit_UnaryOp

self.addUNARYOP(op, code)

File “C:\Users\Singularity zero\zerynth2\dist\r2.3.2\ztc\compiler\astwalker.py”, line 1172, in addUNARYOP

code.addCode(OpCode.UADD())

AttributeError: type object ‘OpCode’ has no attribute ‘UADD’

In case you want to see the code I am trying to upload, here it is. To give you a little context it’s a thermostat that work in time intervals with changing target temperatures. It also flashes a lead to show which interval numer it has reached. The thermo-measurement and the output to a pin is not yet done.

Oelinator

Created at 2019-09-19 19:26:10.816040

#import clock as clock
import timers
import streams

create a serial port with default parameters

streams.serial()

initiate pins

pinMode(D1,OUTPUT)

vars initiated#

tshoot=timers.timer()
mins =[10,5] #ad the minute number to keep each temperature interval
temps =[52,60] #add the temperatures to keep bellow during each temperature interval
i = 0 #i is the current interval. Used to look in the arrays mins & temps, so 0 is the first interval.
temp_reached = False
current_temp =30

sleep(30)

def time_is_up(): # shifts to next interval
i = i+1

while (i <= len(temps)):
if (temps[i] > current_temp):
heat = True
else:
heat = False
if temp_reached == False:
temp_reached = True
# create and start a new timer
tshoot.one_shot(mins[i]601000, time_is_up)

while (True):
counter = 0
digitalWrite(D1,HIGH) # turn the LED ON by making the voltage HIGH
sleep(100) # wait for timeON
digitalWrite(D1,LOW)
sleep(100)
counter =+1
if (counter == i + 1):
counter = 0
sleep (300)

print (“interval: “, i,”, target_temp:”, temps[i],", currrent_temp: “, current_temp,”, heat: ", heat)

Thanks ! :slight_smile:

-Martin


#2

Hi!

It dawned on me that I could disable parts of the code to figure out which part that caused the issue. It turns out it was the callback from the count-down that made the code puke errors.

The problem is solved and you can disregard this thread.

-Martin