const functionName =
Blockly.Python.provideFunction_('serial_get_command', `
def ${Blockly.Python.FUNCTION_NAME_PLACEHOLDER_}():
while True:
ser.flushInput()
ser_read_buff = ser.readline()
try:
serobject = json.loads(ser_read_buff)
if serobject["function"]:
function_name = serobject["function"]
param = serobject["param"]
print(function_name)
print(param)
command = f"{function_name}({param})"
except json.JSONDecodeError:
pass
`);
Blockly.Python.finish = function(code) {
return code+"\n"+functionName+"()";
} I use these code to both generate head function and end command
but if i write finish command, the head function disappear, what's wrong?