Instead of trying to go through kernel32 which is awkward at
the least
to talk to a serial port I would try to figure out if Hyperterminal can
actually properly talk through your interface as suggested in the other
thread. Writing to a serial port is not just calling WriteFile but you
also need to setup some seetings of the serial port beforehand.
Although your main problem here is probably that the
nNumberofBytrsTowrite is not passed by reference (pointer) but as value
instead according to the documentation of WriteFile on MSDN. Also the
lpOverlapped pointer should be configured as an uInt32 passed by value
instead, since you don't want the function to believe there is an
overlapped structure it should try to interprete. And while you at it
reconfigure the lpBuffer parameter as an array of uInt8 values and wire
the output of the String To Byte Array fucntion to this parameter. This
way it will also work for strings that are not exactly four bytes long.
Your USB driver seems to not completely behave as a COMM driver
should and VISA stumbles over this behaviour. If Hyperterminal can talk
through your device driver then VISA may be the trouble indeed but it
is still likely that the USB device manufacturer has a new driver
version too which might fix this anamoly as well. If Hyperterminal
doesn't work either the USB driver is surely and 100% at fault.
Also if Hyperterminal does work I'm sure the guys from VISA development
might be interested to get more information about what USB device that
is to investigate the cause of the problem, in order to be able to get
a bugfix or maybe workaround into the next VISA release.
Rolf Kalbermatter
Message Edited by rolfk on 12-30-2005 11:09 AM