Type error on popup containing custom function

Hi all,

I have implemented a custom function based on a previous question I asked here on the forum: Link to question

I chose the implementation where I add a function. This worked fine until I tried to test it out.

This is the code in my InstallationNodeContribution generateScript method:

        writer.appendLine("def readpmc(address, dataType, dataNumber):");
		writer.appendLine("\t cnc.rdpmc(address, dataType, dataNumber)");
		try {
			System.out.println("Generating function!");
			FunctionModel functionModel = apiProvider.getInstallationAPI().getFunctionModel();
			functionModel.addFunction("readpmc", "address", "dataType", "dataNumber");
		}catch (Exception e) {
			// TODO: handle exception

This is the error I’m getting:

Type error: left-hand side of the expression expected type ''int / float/ bool / string 
/ pose' but found 'None'

Script code
global var_1 = cnc.rdpmc(5,0,800)
$ 4 "var_2=readpmc(5,0,800)"
global var_2=  readpmc (5, 0, 800)
$ 5 "Popup"
popup(str_cat("", var_2), "Message", False, False blocking=True    <--- line that causes error

My guess is that it is caused because there is no return value from my readpmc to display in the popup? Can someone tell me if this is the case?

Yep I would say that’s what the issue is. Your readpmc() function calls cnc.rdpmc() and then quits. It needs to return the output of that function call, whatever it is