Benjames - 2022-10-04

Hello,

While working with codesys v2.3 to send data to a wireless modem, we created an application that receives serial data from codesys.
The AT commands come through appropriately and we respond to them: see code snippet and codesys settings.
After we reply with β€˜\r\nβ€œCONNECT”\r\n’, we stop hearing anything from codesys, until the timeout time (30s) is reached. Then codesys starts spewing a few unicode characters (such as β€œ??\u0005\0\u0001\0?\u0001B???\0” - can't read in c#) before it breaks with expected (and readable in c#) β€˜+++’.

The question we have is twofold:
What should we implement or change to have codesys send the data after the connect reply?
What do those terminating unicode characters mean?

        public void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            rxData += serialPort1.ReadExisting();
            if (rxData.Contains("ATV1E\r")){
                serialPort1.WriteLine("OK");
                rxData = "";
                modemConnectedStatus = 1;
            }

            if (modemConnectedStatus == 1){
                try{
                    if (rxData.Contains("\r")){ //we call a phone number with the Dial command: ATDT0612345678
                        id = rxData.Substring(4, rxData.Length - 5);
                        serialPort1.WriteLine("\r\nCONNECT 9600\r\n");
                        rxData = "";
                        modemConnectedStatus = 2;
                    }
                }
                catch{
                    break; 
                }
            }
        }
        if(modemConnectedStatus ==2){
            try{
                Console.Write(rxData);
            }
            catch{
                break;
            }
    }
 

Last edit: Benjames 2022-10-04