OnComm event with JavaScript doesn't fire

R

Roman Bystrianyk

I'm trying to get a comm port working from a javascript using an
ActiveX control. The port is basically working where I can receive
input from the serial port. BUT - I can't seem to get the OnComm
event working so can receive the incomming characters async - any
ideas????

Thanks!
Roman

var MSComm1 = new ActiveXObject("MSCOMMLib.MSComm");

function onTextClick() {
view.beginAnimation(doRotation, 0, 360, 500);

MSComm1.CommPort = 1;

if (MSComm1.PortOpen == false)
{
MSComm1.Settings = "57600,n,8,1"
MSComm1.SThreshold = 1;
MSComm1.RThreshold = 1;
MSComm1.RTSEnable = 1;
// MSComm1.InBufferSize = 1;
MSComm1.InputLen = 1;
MSComm1.InputMode = MSComm1.comInputModeText;
MSComm1.PortOpen = true;
}

msg = "Test Message ";
// MSComm1.Output = msg;
msg = MSComm1.Input;

while(msg == "")
{
msg = MSComm1.Input;
}

alert(msg);

// MSComm1.PortOpen = 0;
// MSComm1.AboutBox();
}

function MSComm1_OnComm(){

alert("onComm");

}

function doRotation() { mylabel.rotation = event.value; }
 
D

dmark

I'm trying to get a comm port working from a javascript using an
ActiveX control.  The port is basically working where I can receive
input from the serial port.  BUT - I can't seem to get the OnComm
event working so can receive the incomming characters async - any
ideas????

Thanks!
Roman

var MSComm1 = new ActiveXObject("MSCOMMLib.MSComm");

function onTextClick() {
  view.beginAnimation(doRotation, 0, 360, 500);

        MSComm1.CommPort = 1;

        if (MSComm1.PortOpen == false)
        {
                MSComm1.Settings = "57600,n,8,1"
                MSComm1.SThreshold = 1;
                MSComm1.RThreshold = 1;
                MSComm1.RTSEnable = 1;
        //      MSComm1.InBufferSize = 1;
                MSComm1.InputLen = 1;
                MSComm1.InputMode = MSComm1.comInputModeText;
                MSComm1.PortOpen = true;
        }

        msg = "Test Message ";
//      MSComm1.Output = msg;
        msg = MSComm1.Input;

        while(msg == "")
        {
        msg = MSComm1.Input;
        }

alert(msg);

//      MSComm1.PortOpen = 0;
//      MSComm1.AboutBox();

}

function MSComm1_OnComm(){

This isn't VB. See if the object has an oncomm property. If so, set
it to reference this function.
 
R

Roman Bystrianyk

This isn't VB.  See if the object has an oncomm property.  If so, set
it to reference this function.- Hide quoted text -

- Show quoted text -

After working on this problem for quite a while I still haven’t found
a solution. The “OnComm” method is available in C++ and VB, however,
there seems to be no way to set or access this method using
javascript.

C++:

void CAboutDlg:: OnCommMscomm1()
{
// TODO: Add your control notification handler code here

}

VB:

Private Sub MSComm1_OnComm()
Dim InBuff As String

Select Case MSComm1.CommEvent
. . .
End Select

End Sub


Does anyone know if there is someway to get to this method in
javascript? Is this at all possible?

Thanks!
Roman
 
D

David Mark

After working on this problem for quite a while I still haven’t found
a solution.  The “OnComm” method is available in C++ and VB, however,
there seems to be no way to set or access this method using
javascript.

Again, did you try the "oncomm" *property* of the object?

Something like:

MSComm1.oncomm = function() {
alert("onComm");
};

Or maybe it wants "onComm"? Use typeof to find out. Or type convert
and the one that explodes is it.

Or maybe you can't do it. Did you try MSDN? And you can have
VBScript and JScript in the same page, so I really can't see your
problem.
 
R

Roman Bystrianyk

Again, did you try the "oncomm" *property* of the object?
Something like:

MSComm1.oncomm = function() {
    alert("onComm");

};

Or maybe it wants "onComm"?  Use typeof to find out.  Or type convert
and the one that explodes is it.

Or maybe you can't do it.  Did you try MSDN?  And you can have
VBScript and JScript in the same page, so I really can't see your
problem.

Thanks for the information!

What I was trying to do was use JavaScript to access a comm port
inside of a Google sidebar gadget. I thought that since the property
OnComm was available via C++ and VB that it was also be available via
JavaScript. Using your examples and typeof I get back that the
"Object doesn't support this property or method" or "undefined". So
it seems that this method is not available for JavaScript for some
reason. Anyone have any ideas why this is? I may go to a polling
method to get characters from the comm port instead of using the nicer
callback method. OR maybe as you suggest I can put the VBScript
somehow into the google gadget - I have to look into that option as
well. I didn't find anything under MSDN or anywhere on the web.

Thanks again for the input.

Have a great day!
Roman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,129
Messages
2,570,770
Members
47,326
Latest member
Itfrontdesk

Latest Threads

Top