locked
MSComm or Serial Port Communication RRS feed

  • Question

  • User459026036 posted

    Hi All,

    how do i access MSComm or do serial port communication on the client side using javascript.

     

    Any help is highly appreciated.

     

    thanks

    fairozkhan

    Monday, September 26, 2011 4:06 AM

All replies

  • User459026036 posted

    i have created a simple COM dll in c# framework 2.0 and trying to access it. I am getting "cannot create object error".

    dll code

    <code>

    namespace

    COM_Frame2

    {

       

    public interface iClass1


        {

           

    int getAge();

        }

        [

    ClassInterface(ClassInterfaceType.AutoDual)]   

       

    public class Class1: iClass1


        {

           

    public Class1()

            {

            }

           

    public int getAge()

            {

               

    return 30;

            }

        }

    }

    </code>

     

    client side

    <code>

    function

    AccessComm() {

           

    var obj = new ActiveXObject('COM_Frame2.Class1');       

           

    var res;

           

    var data;

           

    if (obj == null) {

                alert(

    'Error Creating DLL');

            }

           

    var res = obj.OpenPort();

           

    if (res == 0) {

                alert(

    'Error');

            }

           

    else {

                data = obj.Data;

                alert(data);

            }

           

        }

    </code>

     

    Any help is highly appreciated.

    Monday, September 26, 2011 6:13 AM