Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dll for Kit
#1
http://www.vellemanusa.com/support/down ... 055&type=9

Any way to get this to work in QM? I can't get the DLL to register...most likely .NET and not COM.

Is there anyway to convert? Or am I just stuck. I sure would prefer to not be stuck.

Thanks,
Jim
#2
It is simple dll, not COM or Net.

Read K8055_DLL_manual.pdf and declare the functions in QM. Function declarations there are in C++ language.

Macro Macro1584
Code:
Copy      Help
dll kb8055d
,#OpenDevice CardAddress
,CloseDevice
,...
#3
Ok. I was trying to register it with QM and it failed. I'll try it out later and see if I can get it to work.

Thanks!
Jim
#4
I don't know how to set up the dll and execute commands really with QM.

Ok, so I've gotten the the kit to execute one command using (I haven't set up all the functions of the dll because you cannot copy and paste from the pdf, so I'd either have to rekey or convert the pdf):
Code:
Copy      Help
out
dll K8055D
,#OpenDevice CardAddress=0
,#OutputAnalogChannel
,#WriteAllDigital
,#CloseDevice
,#ClearAllDigital
OpenDevice(0)
WriteAllDigital(9)

If I try to run again I get:
Exception 0xEEDFADE. In KERNELBASE.dll at 0x75E2B760 (0x75E20000+0xB760).

When I restart QM I get this error:
   


Like I said, I know I am doing this all wrong. I'm actually pretty excited to see QM execute at least one command!!

Thanks,
Jim
#5
Why =0?

Macro Macro1569
Code:
Copy      Help
out
dll K8055D
,#OpenDevice CardAddress
,CloseDevice
,OutputAnalogChannel Channel Data
,WriteAllDigital Data
,ClearAllDigital
int cardAddress=OpenDevice(0)
if(cardAddress=-1) end "error"
WriteAllDigital(9)
5
CloseDevice
#6
You can have more than one device that are assigned an address by jumpers on the board.

I have both jumpers on so the device id is 0.

Still I have the exact same issues.

I can run the function once and then the same things happen.

It will run multiple commands:
Code:
Copy      Help
out
dll K8055D
,#OpenDevice CardAddress
,CloseDevice
,OutputAnalogChannel Channel Data
,WriteAllDigital Data
,ClearAllDigital
int cardAddress=OpenDevice(0)
if(cardAddress=-1) end "error"
WriteAllDigital(9)
1
WriteAllDigital(7)
1
WriteAllDigital(122)
1
WriteAllDigital(144)
5
CloseDevice

but if I try to run the function again, same errors as above.

-jim
#7
I guess what I am asking, is how do I open the device in one function and then send commands in other functions?
#8
Probably cannot be opened/closed two times in process. For easier testing, run in separate process.

or

Macro Macro1569
Code:
Copy      Help
out
dll K8055D
,#OpenDevice CardAddress
,CloseDevice
,OutputAnalogChannel Channel Data
,WriteAllDigital Data
,ClearAllDigital

int+ g_kit
if(!g_kit)
,g_kit=OpenDevice(0)+1
,if(!g_kit) end "error"
,;or put this code in a function that runs at startup

WriteAllDigital(9)

;CloseDevice ;;call it when QM exits, for example in a function with trigger "QM events -> file unloading", or from a destructor of a global variable.
#9
I would use this function to open and close. Not tested.

Function KitInit
Code:
Copy      Help
;/
function# [close]

;Opens or closes kit.
;Error if fails to open.
;On Open returns kit card address.
;Can be called many times. If already open, will not try to open again. Error if already closed.

;Call this function before using kit functions:
;<code>KitInit</code>

;Call this function when QM exits, for example in a function with trigger "QM events -> file unloading", or from a destructor of a global variable:
;<code>KitInit 1</code>


dll K8055D
,#OpenDevice CardAddress
,CloseDevice
,OutputAnalogChannel Channel Data
,WriteAllDigital Data
,ClearAllDigital

int+ __g_kit ;;0 not opened, -1 closed, >0 open

if(__g_kit=-1) end "don't call this function after closing"

if close
,if __g_kit
,,__g_kit=-1
,,CloseDevice
,ret

if !__g_kit
,lock
,if !__g_kit
,,__g_kit=OpenDevice(0)+1
,,if(!__g_kit) end "failed to open kit"

ret __g_kit-1
#10
So if I use a dialog to initialize the KitInit, I can then executed commands from separate functions as long as the dialog is open.

If I close the dialog and reopen it, none of the commands works until I restart QM where I get the same runtime error. Once QM restarts, I can run the dialog and execute commands again.

Function InitKitDlg
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;END DIALOG
;DIALOG EDITOR: "" 0x2030208 "" "" ""
if(!ShowDialog("InitKitDlg" &InitKitDlg)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,KitInit
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#11
Then probably thread that called OpenDevice or KitInit must be running all the time.

dialog:
mac "kit_thread"

Function kit_thread:
KitInit
atend KitInit 1
wait -1

For kit_thread check "Allow only single instance".

Or, let the dialog run all the time. Instead of closing - hide. Next time, if dialog exists, show it.

Or try this:
DisableThreadLibraryCalls GetModuleHandle("K8055D")
Then the dll will not know that the thread ended.


Forum Jump:


Users browsing this thread: 1 Guest(s)