How to use comopen function in multiprocess mode or replace with msgrpc ?

I have old communication with scales which work with older version Citect in Single process mode.

Actually we have two IOServers and working in multiprocess mode this communication stop working now.

I read in knowledge base to use msgrpc, because comopen always return -1 in multiprocess.

How to use comopen in multiprocess mode or use msgrpc ?

Parents
  • Hi  ,

    Can you share what error you are seeing when calling ComOpen?

    If you have two I/O Servers, can you check the name of the Board and Port defined?

    The ComOpen requires the Port Name as defined in the ports database.

    MsgRPC is only required if you are trying to run code on a remote process. For example you want to call a cicode function from the Client process, but the function is only allowed to be executed on an alarm server, in this case, you would MsgRPC to the alarm server to run the code, the response is then sent back to the client process, where it can be used (e.g. logged or used on a display value).

  • ComOpen RETURN -1

    For ComOpen i have defined on PORTS (IOServer    PORT1_BOARD2    3    BOARD2    9600    8    2    NONE)

    Then in Cicode i have :

    INT
    FUNCTION
    StartSerial(INT iPrint = 1, STRING sFile = "", INT iTime = -1)
    	INT	hPort;
    	STRING sFileName;
    	
    	hPort = ComOpen("PORT1_BOARD2", 0);
    	
    TraceMsg("hPort = " + IntToStr(hPort));
    
    	IF hPort < 0 THEN
    		
    		RETURN -1;
    		LogowanieZdarzenia("BRAK KOMUNIKACJI Z WAGĄ","---","CITECT");
    	END
    	
    	sFileName = SerialWrite(hPort, sFile, iTime);
    	ComClose(hPort);
    	
    	IF iPrint = 1 THEN
    		FormPrintFile(sFileName,"NOTEPAD");
    	END
    	
    	RETURN 0;
    END

Reply
  • ComOpen RETURN -1

    For ComOpen i have defined on PORTS (IOServer    PORT1_BOARD2    3    BOARD2    9600    8    2    NONE)

    Then in Cicode i have :

    INT
    FUNCTION
    StartSerial(INT iPrint = 1, STRING sFile = "", INT iTime = -1)
    	INT	hPort;
    	STRING sFileName;
    	
    	hPort = ComOpen("PORT1_BOARD2", 0);
    	
    TraceMsg("hPort = " + IntToStr(hPort));
    
    	IF hPort < 0 THEN
    		
    		RETURN -1;
    		LogowanieZdarzenia("BRAK KOMUNIKACJI Z WAGĄ","---","CITECT");
    	END
    	
    	sFileName = SerialWrite(hPort, sFile, iTime);
    	ComClose(hPort);
    	
    	IF iPrint = 1 THEN
    		FormPrintFile(sFileName,"NOTEPAD");
    	END
    	
    	RETURN 0;
    END

Children
  • So your StartSerial() function needs to run in the IOServer process. You could put a button on a page (which runs in the Client process) to call MsgRPC() to tell it to run StartSerial() in the IOServer. Or, you could run the Computer Setup Wizard and set it to call StartSerial() from the IOServer process like this: 

    Another option is to use an Event to call StartSerial() periodically, and you use the Setup Wizard to enable that event to run in the IOServer process. You have to make sure not to start multiple copies of your event, but then if your function terminates because of a fatal error, the event will restart it.

  • 1. I will try with button MsgRPC(hMsg, sName, Arg, Mode).
    I don't quite understand the syntax MsgRPC to use IOServer. For hMsg MsgOpen(IOServer, 1, ?) ?       
    2.The solution with the call event performed once a day seems fine for me.
    The event should be pinned to the same IOserver as the configurated port ?

    PORT:        

    Event pinned to the same IOServer