01-09-2010 11:34 AM
Hello, I'm working with C Code, and I'm trying to get it into LabVIEW. I'm pretty new at this, although I'm learning alot in the process by going through the forums!
My question deals with the #define directive. I'm currently trying to control a Star-Dundee USB Brick Spacewire device, and I don't think I'm setting the speed correctly. Using a dll, here is the function which is called:
CFGSpaceWire_SetBrickBaseTransmitRate(*phDevice, CFG_BRK_CLK_200_MHZ, CFG_BRK_DVDR_1, 0xff);
CFG_BRK_CLK_200_MHZ is defined as:
#define CFG_BRK_CLK_200_MHZ (BIT2 | BIT0)
BIT2 and BIT0 are defined as:
#define BIT0 (0x00000001)
#define BIT2 (0x00000004)
What's the best way to implement the CFGSpaceWire_SetBrickBaseTransmitRate using the .dll? Can this be translated into unsigned or signed bits, or would I need to do more than that?
Thanks,
Andrea
01-09-2010 11:42 AM
0x00000001 is U32. The pointer might be more problematic, from where do you get it (dll call). And 0xff should be U8
Felix
01-11-2010 01:53 AM
F. Schubert wrote:0x00000001 is U32. The pointer might be more problematic, from where do you get it (dll call). And 0xff should be U8
Felix
To assume that a constant 0xff is automatically indicating an 8 bit parameter is a bit unsafe. C compilers do have a thing called automatic numeric adaption or something like that, so independant what the parameter type is, it will do the right thing (unless you define a numeric constant that is bigger than the parameter type can handle in which case a selfrespecting compiler should give at least a warning).
To be sure how the Call Library node needs to be configured one should really consult the function prototype. As to the orignal question, the easiest to get those numbers is to create a numeric constant and define its numeric format to be Hexadecimal and just enter the according numbers into it. The OR definition will then have to be computed on the diagram or you just do that once in your head and enter the according number.
01-12-2010 04:41 PM
Would (BIT2 | BIT0) equal 6 in U32 format?
Thanks,
Andrea
01-12-2010 06:48 PM
For constants, you can use the 'Format & Precision' right-click and select binary. Then you can directliy enter 101.
Felix
01-13-2010 12:41 AM
AndreaD wrote:Would (BIT2 | BIT0) equal 6 in U32 format?
Thanks,
Andrea
Actually in this case it is the sum of the two values, so 5. But OR isn't generally just a sum, unless none of the bits from the two values overlaps which it does not in this case since the constants are obviously bit flags.
04-29-2010 06:12 PM
Andrea,
How is that SpaceWire Interface going?
I am barely getting started on a similar effort so any of your lessons learned would be a great help.
What specific Hardware are you attempting to configure and utilize?
I am interfacing to the PCI-Spacewire card made by Dynamic Engineering. I'm sure I'll be faced with the same C code into Labview that I have read about in your posts..
Have you gotten yours working yet? Would you be willing to share your vi?
Did you utilize any of the VISA tools or just translate C to Labview somehow?
I'm clueless right now but trying to gather as much info before I get started.. I won't have the hardware for a while yet..
Thanks,
John
09-22-2010 03:45 PM
John,
Did you have any luck in creating your Spacewire Driver for the Dynamic Engineering Card?
Sam