LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CLN - 1-wire TMEX drivers - calling TMNext - returning pointer memory location

Summary
~~~~~~~~~~~~~~~~~~~~~~
How do I call this function from a Call Library Node?
 
short far pascal TMNext(
long session_handle,     // session handle for the desired 1-Wire network
void far *state_buffer   // state buffer provided for the 1-Wire network session
);
 
Background
~~~~~~~~~~~~~~~~~~~~~~
Hiya,
I searched the forum for 1-wire drivers, but it doesn't seem that there are any. So I thought I'd write some (if I manage it, I'll post them back here) - they'd probably be useful for someone else. They call the functions used by the TMEX 1-wire drivers http://www.maxim-ic.com/products/ibutton/software/tmex/index.cfm
 
I've managed to get TMExtendedStartSession and TMSetup to work (or, at least, not crash), but I'm struggling to get the TMNext function to work. The problem seems to be getting the correct settings for *state_buffer. This seems to be an array of bytes, dimensions 0 to 15360, but I get a bit baffled by pointers - I think I understand them in principle, but in practice, I usually end up in a bit of a mess!
 
How to configure?
Numeric or Array? Or adapt to type?
Pointer to Value, Array Data Pointer, etc?
Do I need to dimension a Labview array to 15360 (or 15361) and pass it to the CLN to get the correct array back?
 
Here is a C example from the support documentation , or I've got a VB example if you'd prefer.
 
long session_handle;
unsigned char state_buffer[15360];
short result, cnt = 0;

/* session_handle set from a call to TMExtendedStartSession */
...

/* attempt to find the first device on 1-Wire network */
result = TMFirst(session_handle, state_buffer);

/* loop to count all of the devices on the 1-Wire network */
while (result > 0)
{
   cnt++;

   /* find next device */
   result = TMNext(session_handle, state_buffer);
}

/* close the session with a call to TMEndSession */
...
I'd be very grateful for advice on this - I think if I can get this cracked then CLNs will no longer be the scariest icon on the Labview functions palette. 
Many Thanks
 
Joolz
 
0 Kudos
Message 1 of 2
(3,726 Views)

Hi,

  if I'm understanding this correctly, the state buffer is an array of U8's that gets filled in by this function.

You need to do an initialise array of the U8 type of the appropriate size, and then pass this into the dll at the appropriate parameter.

See the following example code item for a better explanation :

http://venus.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_answer=&p_guid=C9914D5A718C627EE034080...

This should work for you, but failing that, you could always wrap it's functionality with a c-based environment, and pass the values to that from LabVIEW< using it as a means of performing the conversion.

Hope that helps

Sacha Emery

National Instruments (UK)

// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 2 of 2
(3,701 Views)