I am trying to control a bench multimeter (GW Instek GDM-8251A) from excel/vba. I could not find a description of the protocol so I need to reverse engineer it.
The communication method is serial over usb.
So I have loaded in VBA the module from the following page with offers functions for talking to the COM ports using the windows API.
http://www.thescarms.com/vbasic/commio.aspx
Which had been recommended from a previous SO thread
So the plan was to open the supplied DMMVIEWER application and listen on the traffic to and from the device.
However the issue is that when I run the CommOpen function, which itself calls the CreateFile win32 API, I get the following error if the DMMVIEWER is already running.
The exact parameters are as follows
CreateFile(strPort, GENERIC_READ Or _
GENERIC_WRITE, 0, ByVal 0&, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
or exactly this
CreateFile( "COM4", -1073741824 , 0 , 0 3 ,128 ,0)
This returns the following error.
COM Error: Error (5): CommOpen (CreateFile) - Access is denied.
I have the alternative of using wireshark in usb capture mode, but then all the USB overhead is making it even harder to understand the underlying protocol.
Also doing this from excel/vba makes it much easier to experiment sending data and seeing what happens.
So my question is this. How can I open a COM port in a non-exclusive read mode so that I can sniff serial traffic ?
Thanks !
I plan to release my findings about the protocol and the VBA code to the sigrok.org project BTW.
(BTW I tried freeserialanalyzer.com but it was extremely limited 15 day trial and limited to 5 captures, which wasn't even enough to configure the capture properly, also this software is so expensive that I couldn't even find the price, probably like 800$. I also tried realterm, which can save serial stream to text, however the sniffing an existing connection requires a special driver which I couldn't find and apparently requires a donation. I tried portmon but the capture option remained grayed out)