LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

#Define C Code to LabVIEW

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 

0 Kudos
Message 1 of 8
(3,578 Views)

0x00000001 is U32. The pointer might be more problematic, from where do you get it (dll call). And 0xff should be U8

 

Felix

0 Kudos
Message 2 of 8
(3,577 Views)

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.

Rolf Kalbermatter
My Blog
Message 3 of 8
(3,528 Views)

Would (BIT2 | BIT0) equal 6 in U32 format?

 

Thanks, 

Andrea 

0 Kudos
Message 4 of 8
(3,472 Views)

For constants, you can use the 'Format & Precision' right-click and select binary. Then you can directliy enter 101.

 

Felix

0 Kudos
Message 5 of 8
(3,460 Views)

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. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 8
(3,442 Views)

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

 

 

0 Kudos
Message 7 of 8
(3,182 Views)

John,

 

Did you have any luck in creating your Spacewire Driver for the Dynamic Engineering Card?

 

Sam

0 Kudos
Message 8 of 8
(2,943 Views)