Please surround your code with:
try {
// your code
} catch(ex if ex instanceof WinError) {
Print( ex.text, ' ', ex.const, ' (', ex.code, ')', '\n' );
}
and give me the output. This will help me to understand what is going wrong.
Thanks,
Franck.
> --
> Group jslibs - http://groups.google.com/group/jslibs -
> jsl...@googlegroups.com
> Unsubscribe: jslibs-un...@googlegroups.com
var player = createComObject("DecklinkPlayback");
try{
player.SelectCard(0);
}
catch(ex) {
print( ex.text, ' ', ex.const, ' (', ex.code, ')', '\n' );
}
C:\Stuff\devel\seq>jshost -l 1 comtastic.js
The parameter is incorrect. E_INVALIDARG (2147942487)
Having seen this, I have tried various arguments (0, 1, '0', '1') with no
success (and it shouldn't crash if I pass a bad arg anyway).
P
This machine may not have the right hardware to run this. We might have to
wait until I get a replacement PCI card, since the one I was using is
faulty. Hopefully this will happen this week.
However, I suspect that this error information is still valid - it shouldn't
crash in these circumstances anyway.
P
> --
> Group jslibs - http://groups.google.com/group/jslibs -
> jsl...@googlegroups.com
> Unsubscribe: jslibs-un...@googlegroups.com
--------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.432 / Virus Database: 270.14.125/2600 - Release Date: 01/04/10
19:35:00
var serial = createComObject("NETCommOCX.NETComm");
serial.commPort = 0;
serial.RThreshold = 1;
serial.settings = '115200, N, 8, 1';
serial.portOpen = true;
try {
serial.OnComm = function(){
print('Comms event received');
}
}
catch(ex) {
print( ex.text, ' ', ex.const, ' (', ex.code, ')', '\n' );
}
C:\Stuff\devel\seq>jshost -l 1 comtastic.js
Unknown name. DISP_E_UNKNOWNNAME (2147614726)
In light of this, I have also tried "oncomm", "OnComm" etc with the same
results.
This may be complicated. In WSH, the only way to capture a "comm" event is
to do this:
serial = WScript.CreateObject("NETCommOCX.NETComm","serial_");
function serial_OnComm(){...}
You cannot do this:
serial = new ActiveXObject("NETCommOCX.NETComm");
serial.oncomm = function (){...}
I don't understand what the internal implementation differences are here. I
can possibly ask a friend who is a real expert on this, but it's possible
that the serial OCX doesn't have a conventional property named "oncomm". It
is also possible that we may have to poll the serial.inputData property to
see if there's anything there, if jslibs cannot assign a callback.
P
It seems to me that, if jslibs does not implement an event loop like (for
instance) a web browser does, then there is no way to avoid having something
like a doComEvents() method for COM objects.
This is a perfectly fine solution, whether doEvents() is a property of COM
instances, or whether you do it like poll(). I favour the poll() approach.
One problem with this is that any of these techniques involve queueing up
COM object events, which will require saving a lot of state information
about the COM instance to go along with each event, and I don't know how
hard that is to do.
In the long term you might want to think about some sort universal solution
to event handling which would work for polled descriptors, COM objects, and
similar situations. WSH doesn't do this very well but may offer some ideas.
I'm not exactly sure what its logic is, but it seems to handle events
whenever you return from a sleep in the global scope. One approach might
actually be to make sleep() interruptible, like the delay on a poll(), with
the syntax:
sleep(int delay, bool interruptible = false)
JSlibs should not become multi-threaded so I propose that in this situation
the stack should be dumped (as in a throw) and execution returned to the
global scope, whereupon any outstanding events would be run. In most
practical circumstances, an interruptible sleep would mainly be used in the
global scope so this would not be confusing, and it allows the usual
approach with some advantages:
while(true) {
sleep(60*1000, true)
}
// EOF
In this case, the interpreter does not have to wake up very often unless
there are events and events are fired with no delay. You would need to
provide an onEndSignal event to allow the script to be killed, and it would
also be a good time to implement timers similar to setTimeout() and
setInterval() in web browsers.
I think it is important that something like this is done, because at the
moment, if COM events were available -and- we wanted to use polled
descriptors, we would need a loop like this:
while(true) {
poll(pollTargets,pollDelay);
doComEvents();
sleep(n);
}
While this can be written in Javascript, there will be a performance
penalty, and the more event-oriented objects we get, the more complex and
unpleasant that will become.
Does any of this make sense?
P
eg.
MetaPoll( StartOIPool([s1, s2]), StartSDLPoll(),
StartWinCOMPoll(xhr), StartEndSignal(), StartTimeout(50) );
Franck.
I think that's absolutely fine and needs to be done ASAP, otherwise COM is
not very useful. Can poll() be renamed to reflect the fact that it only
handles NSPR-related events?
My only remaining concern is that you will have to store a lot of state
information about the COM object with each event. If a COM object were to
need to fire two or more events during a polling interval, each event would
need to be run in the context of the COM object as it was at the time the
event was fired. Normally COM objects do not run in separate threads and I
wonder if this is automatically handled by the COM architecture somehow.
My final question may seem a bit pushy, but I don't intend it to be that
way. My project definitely requires COM event handling, and I don't want to
spend a lot of time developing code for jslibs if it's going to be a very
long time before COM events are working. On the other hand, I would much
prefer to use JSlibs than WSH. Is there an ETA on this?
P
Franck.
--------------------------------------------------------------------------------
> --
> Group jslibs - http://groups.google.com/group/jslibs -
> jsl...@googlegroups.com
> Unsubscribe: jslibs-un...@googlegroups.com
--------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.432 / Virus Database: 270.14.130/2607 - Release Date: 01/08/10
07:35:00