RS-232 not working on windows 10 ioT

1.3k views Asked by At

Currently I have a simple working windows form application running on windows 7 embedded that talks serially with a scanner. I wish to switch over to windows 10 ioT platform and be able to run the same application on windows 10 ioT enterprise (Build version 14393 ). As I tried running the same application on windows 10 ioT, the pc hangs up as soon as I try to open a serial port to start communication. However I am able to establish serial communication using a USB to RS-232 cable instead of using a COM Port on the PC using the same win form application.

Further, a tried running a sample UWP serial application here , which still did not detect any scanners connected over RS-232 but was able to connect a USB to RS-232 device.

Is RS-232 communication not supported on windows 10 iot ? Is there anything that I am missing ?

Here is the code snippet used to open ports (Note: Serial parameters for the COM Port are populated to the structure from an xml file):

            //Structures
           public struct SerialPortConfig
           {               

            public string COMPortNumber { get; set; }
            public string BaudRate { get; set; }
            public string DataBits { get; set; }
            public string Parity { get; set; }
            public string StopBits { get; set; }
            public string FlowControl { get; set; }
            public string StringLength { get; set; }
            public int CommInterval { get; set; }
            public int TimeOut { get; set; }
            public string TermChar { get; set; }
            public string[] StartChar { get; set; }
            public string Handshaking { get; set; }
            public int ReadBufferSize { get; set; }
            public int WriteBufferSize { get; set; }
            public bool DTREnable { get; set; }

        }

        public SerialCommDriver(SerialPortConfig serialPortConfig)
        {
            COMPort = new SerialPort();
            COMPort.PortName = "COM" + serialPortConfig.COMPortNumber;
            COMPort.BaudRate = Convert.ToInt16(serialPortConfig.BaudRate);
            COMPort.DataBits = Convert.ToInt16(serialPortConfig.DataBits);

            if (serialPortConfig.Parity == "Odd")
                COMPort.Parity = Parity.Odd;
            else if (serialPortConfig.Parity == "Even")
                COMPort.Parity = Parity.Even;
            else if (serialPortConfig.Parity == "None")
                COMPort.Parity = Parity.None;
            else if (serialPortConfig.Parity == "Mark")
                COMPort.Parity = Parity.Mark;
            else if (serialPortConfig.Parity == "Space")
                COMPort.Parity = Parity.Space;

            if (serialPortConfig.StopBits == "1")
                COMPort.StopBits = StopBits.One;
            else if (serialPortConfig.StopBits == "1.5")
                COMPort.StopBits = StopBits.OnePointFive;
            else if (serialPortConfig.StopBits == "2")
                COMPort.StopBits = StopBits.Two;
            else if (serialPortConfig.StopBits == "None")
                COMPort.StopBits = StopBits.None;

            COMPort.ReadTimeout = serialPortConfig.TimeOut;
            COMPort.NewLine = serialPortConfig.TermChar;

        }
       //End of Structures

     private static SerialCommDriver.SerialPortConfig _SerialPortAConfig;   

     ////Get COM port configuration from xml file  
     XmlNode node3 = document.SelectSingleNode("/LPN/ConfigScannerCOMPort");
    _SerialPortAConfig.COMPortNumber = 
                  node3.SelectSingleNode("COMPort").InnerText;
    _SerialPortAConfig.BaudRate = 
                  node3.SelectSingleNode("BaudRate").InnerText;  
     ................................                                                  
     ................................                                    
     ................................

    _SerialPortA = new SerialCommDriver(_SerialPortAConfig);                                                       

    //***********Subscribe to COM port events.
    _SerialPortA.COMPort.DataReceived += 
                       SerialPortA_NewDataReceived;

         public static void Start()
         {

         .........
         .........
            //Open COM ports.
            try
            {
                _SerialPortA.OpenPort();
                Debug_Log("Port from scanner (" + 
            _SerialPortA.COMPort.PortName + ") is open!", 
          _RunningAsService);



            }
            catch (Exception e)
            {
                Debug_Log("Unable to open required COM port(s). " + 
             e.ToString() + "", _RunningAsService);
                Exit(_RunningAsService);
            } 
            .......
            .......

         }

        public bool OpenPort()
        {
            if (!COMPort.IsOpen)
                COMPort.Open();
            return COMPort.IsOpen;
        }  
0

There are 0 answers