USB that is not a COMM port
-
- Posts: 24
- Joined: Sep 08, 2010 20:27
- Location: Florida
USB that is not a COMM port
I have received help from phishguy on how to talk to a COMM port, however this latestdevice I am trying to talk to shows up as a HID. It apparently has a built in microcontroller. So now COMM, I would like to talk to it in FreeBasic and not get into C or any other program language if I can.
The device is a 24 bit DIO card from CyberReasearch. The UMDIO 24L
The device is a 24 bit DIO card from CyberReasearch. The UMDIO 24L
From looking at the documentation and installing the driver files, there appears to be a Visual Basic example of using the CBW32.DLL file to communicate with this card. It doesn't look like it would be too difficult to convert this to work with Freebasic. The file name of the example function declarations CBW.BAS and there are numerous example files for communicating with different models of their cards.
-
- Posts: 24
- Joined: Sep 08, 2010 20:27
- Location: Florida
USB that is not a COMM Port
phishguy to the rescue. Did you get that from the CyberResearch web site?
I went there and downloaded the manual for the part but didn't see what you are talking about. Did I not dig deep enough?
I went there and downloaded the manual for the part but didn't see what you are talking about. Did I not dig deep enough?
Here's the link to the downloads. I downloaded the universal driver library, which has the DLL and the example programs.
http://www.cyberresearch.com/store/down ... rodid=5100
http://www.cyberresearch.com/store/down ... rodid=5100
-
- Posts: 24
- Joined: Sep 08, 2010 20:27
- Location: Florida
I created an import library (even though using Lib “dllname” in the declaration will also work) and tested the DLL as well as I could without the actual hardware. The DLL has 6000+ exports and all but ~120 have what appear to be C++ decorated names, and CBW.BAS declares ~100 of these. Here are the batch files I used to create a module definition file and import library for the DLL (remember to delete the decorated names from the DEF file before creating the import library).
And a test app that declares and calls two functions that should work without the hardware.
Code: Select all
@echo off
set basename="cbw32"
path=C:\MinGW\bin;%path%
@echo on
pexports %basename%.dll > %basename%.dll.def
pause
Code: Select all
@echo off
set basename="cbw32"
path=C:\Program Files\FreeBASIC\bin\win32;%path%
@echo on
dlltool -k -d %basename%.dll.def -l lib%basename%.dll.a
pause
Code: Select all
#inclib "cbw32"
extern "windows-MS"
declare function cbGetRevision( _
byref DLLRevNum as single, _
byref VXDRevNum as single ) as integer
declare function cbCStatus( _
byval BoardNum as longint, _
byval CounterNum as longint , _
byref StatusBits as longint ) as integer
end extern
dim as single drn, vrn
dim as longint statbits
print cbGetRevision( drn, vrn ), drn, vrn
print cbCStatus( 0, 0, statbits )
sleep
Code: Select all
0 5 5
126
-
- Posts: 24
- Joined: Sep 08, 2010 20:27
- Location: Florida
As I was looking through my old QB code I realized that the CyberReasearch cards that I used were ISA plug ins in I used the address to talk with them ; IE three 8 bit ports plus one or the configuration. They never were COMM ports. On this project I am doing most of the work and the final deployment on an XP based HP laptop. Hence all of the new issues. This new part (CyberReasearch) uses the same chip , a 8255 part ,24 bit IO .
I will try to understand and implement the latest post(code)
I am somewhat concerned in any Windows based app.
Thanks
I will try to understand and implement the latest post(code)
I am somewhat concerned in any Windows based app.
Thanks
Since it is only a DIO interface, I believe the main fuctions that you would need to use are:
CbDConfigPort
CbDIn
CBDOut
So, since you aren't using all the functions in the universal driver, you would probly only need to declare these along with the status and revision functions that MichaelW posted.
CbDConfigPort
CbDIn
CBDOut
So, since you aren't using all the functions in the universal driver, you would probly only need to declare these along with the status and revision functions that MichaelW posted.
-
- Posts: 24
- Joined: Sep 08, 2010 20:27
- Location: Florida
-
- Posts: 24
- Joined: Sep 08, 2010 20:27
- Location: Florida
Instead of using an import library, you can declare the functions directly. Here is an example. I am not 100% sure if the declarations are correct and am unable to test without the hardware. But, it does compile.
<edit>
The declaration for cbDIn isn't correct. I believe that it should be a pointer for the data value.
Code: Select all
'/* Types of digital input ports */
#define DIGITALOUT 1
#define DIGITALIN 2
'define IO ports
#define AUXPORT 1
#define FIRSTPORTA 10
#define FIRSTPORTB 11
#define FIRSTPORTCL 12
#define FIRSTPORTC 12
#define FIRSTPORTCH 13
#define SECONDPORTA 14
#define SECONDPORTB 15
#define SECONDPORTCL 16
#define SECONDPORTCH 17
#define THIRDPORTA 18
#define THIRDPORTB 19
#define THIRDPORTCL 20
#define THIRDPORTCH 21
#define FOURTHPORTA 22
#define FOURTHPORTB 23
#define FOURTHPORTCL 24
#define FOURTHPORTCH 25
#define FIFTHPORTA 26
#define FIFTHPORTB 27
#define FIFTHPORTCL 28
#define FIFTHPORTCH 29
#define SIXTHPORTA 30
#define SIXTHPORTB 31
#define SIXTHPORTCL 32
#define SIXTHPORTCH 33
#define SEVENTHPORTA 34
#define SEVENTHPORTB 35
#define SEVENTHPORTCL 36
#define SEVENTHPORTCH 37
#define EIGHTHPORTA 38
#define EIGHTHPORTB 39
#define EIGHTHPORTCL 40
#define EIGHTHPORTCH 41
Extern "windows-MS"
Declare Function cbGetRevision Lib "cbw32" ( _
Byref DLLRevNum As Single, _
Byref VXDRevNum As Single ) As Integer
Declare Function cbCStatus Lib "cbw32" ( _
Byval BoardNum As Longint, _
Byval CounterNum As Longint , _
Byref StatusBits As Longint ) As Integer
Declare Function cbDConfigPort Lib "cbw32" ( _
ByVal BoardNum as longint, _
ByVal PortNum as longint, _
ByVal Direction as longint) As Long
Declare Function cbDIn Lib "cbw32" ( _
Byval BoardNum As Longint, _
Byval PortNum As Longint, _
DataValue As Short) As Long
Declare Function cbDOut Lib "cbw32" ( _
Byval BoardNum As Longint, _
Byval PortNum As Longint, _
Byval DataValue As Short) As Long
End Extern
Dim As Single drn, vrn
Dim As Longint statbits
Print cbGetRevision( drn, vrn ), drn, vrn
Print cbCStatus( 0,0, statbits )
'set firstporta to output
print cbDConFigPort(0,firstporta,digitalout)
'set all bits high
print cbDOut(0,firstporta,&hff)
Sleep
<edit>
The declaration for cbDIn isn't correct. I believe that it should be a pointer for the data value.
-
- Posts: 24
- Joined: Sep 08, 2010 20:27
- Location: Florida
-
- Posts: 24
- Joined: Sep 08, 2010 20:27
- Location: Florida