Re: [time-nuts] GPIB on HP5382B counter

2009-10-24 Thread Hal Murray

I'm out of practice with C, but shouldn't
 viScanf(vi, %t, buf);
 be
 viScanf(vi, %t, buf);

[I'm not a language wizard.]

It looks OK to me.  Arrays are passed by pointer.
  buf is the same as buf[0]

The compiler should complain if it is wrong.

A quick google found examples without the .


For production code I'd want to tell viScanf the max length.


-- 
These are my opinions, not necessarily my employer's.  I hate spam.




___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] GPIB on HP5382B counter

2009-10-24 Thread Magnus Danielson

Hal Murray wrote:

   I'm out of practice with C, but shouldn't
viScanf(vi, %t, buf);
be
viScanf(vi, %t, buf);


[I'm not a language wizard.]

It looks OK to me.  Arrays are passed by pointer.
  buf is the same as buf[0]

The compiler should complain if it is wrong.

A quick google found examples without the .


Indeed:
http://zone.ni.com/devzone/cda/tut/p/id/4727

Cheers,
Magnus

___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] GPIB on HP5382B counter

2009-10-24 Thread Chuck Harris

If buf is defined as an array (eg. char buf[100];)
its name is a constant that points to the start of the
array.  You can write it either as buf, or buf.

-Chuck Harris

Brent Gordon wrote:

   I'm out of practice with C, but shouldn't
viScanf(vi, %t, buf);

be

viScanf(vi, %t, buf);

Brent


___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] GPIB on HP5382B counter

2009-10-24 Thread Hal Murray
 If buf is defined as an array (eg. char buf[100];) its name is a
 constant that points to the start of the array.  You can write it
 either as buf, or buf. 

Not quite.  You need buf[0]

  buf is a pointer to the array. (first element)
  buf is a pointer to that pointer.
  buf[0] is a pointer to the first element of the array.


-- 
These are my opinions, not necessarily my employer's.  I hate spam.




___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] GPIB on HP5382B counter

2009-10-24 Thread Tom Van Baak

Not quite.  You need buf[0]

 buf is a pointer to the array. (first element)
 buf is a pointer to that pointer.
 buf[0] is a pointer to the first element of the array.


Hal, try the following with your C compiler...

#include stdio.h
void main ()
{
   char buf[100] = { 3,1,4,1,5 };

   printf(0x%.8lX\n, buf);
   printf(0x%.8lX\n, buf);
   printf(0x%.8lX\n, buf[0]);
   printf(0x%.8lX\n, buf[0]);
}

And see if your results and intuition agree.

0x0012FF1C
0x0012FF1C
0x0003
0x0012FF1C

/tvb


___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.



Re: [time-nuts] GPIB on HP5382B counter

2009-10-24 Thread Magnus Danielson

Hal Murray wrote:

If buf is defined as an array (eg. char buf[100];) its name is a
constant that points to the start of the array.  You can write it
either as buf, or buf. 


Not quite.  You need buf[0]

  buf is a pointer to the array. (first element)
  buf is a pointer to that pointer.
  buf[0] is a pointer to the first element of the array.




Not quite.

Piece of example code:

#include stdio.h

int main()
{
int buf[100];
printf(%p %p %p\n, buf, buf, buf[0]);
return 0;
}

Prints
0xbf933224 0xbf933224 0xbf933224

So they are the same in this context. That's how it works. I could 
detail it in booring details if needed.


Cheers,
Magnus

___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] GPIB on HP5382B counter

2009-10-24 Thread Mike S

At 04:46 PM 10/24/2009, Tom Van Baak wrote...

Not quite.  You need buf[0]
 buf is a pointer to the array. (first element)
 buf is a pointer to that pointer.
 buf[0] is a pointer to the first element of the array.


Hal, try the following with your C compiler...


BASIC is _so_ much easier. :-) 



___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] GPIB on HP5382B counter

2009-10-24 Thread Hal Murray

t...@leapsecond.com said:
 Hal, try the following with your C compiler... 
...

mag...@rubidium.dyndns.org said:
 Not quite. 
...


Argh/blush.  Sigh.

Thanks for the correction, and apologies for cluttering up the list with 
bogus info.

I fished out my old copy of Andrew Koenig's C Traps and Pitfalls.  Chapter 2 
starts with Pointers and Arrays.

It's Copyrighted 1989.  Does anybody know of a other books that cover similar 
material?

It's a very good book and I like the style.  I'm just looking for additional 
info, a second opinion/viewpoint.  Sometimes saying the same thing in a 
different way will click.



-- 
These are my opinions, not necessarily my employer's.  I hate spam.




___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


[time-nuts] GPIB on HP5382B counter

2009-10-23 Thread Jerome Peters

I'm still trying to get the HP5328B counter to work with GPIB.  I don't have 
any problems talking, however I can't receive data.
I think the basic (HP/Agilent) hardware/software  are ok, with a similar type 
of program I am able to send/receive to a 34401 Digital Multimeter.
It seems like it should be pretty straight forward to implement but I can't 
figure out where  I'm going wrong.  There is a test oscillator driving the 
counter at ~5MHz, The Oscillator drifts a bit, so I can see every time it 
captures a new measurement. The counter is not in talk only mode

#include visa.h
#include stdio.h
#include windows.h
#include string.h

void main () {

  ViSession defaultRM, vi;
  char buf[25] = {0};
  char buf1[25] = {Press Return to exit};

  /* Open session to GPIB device */
  viOpenDefaultRM (defaultRM);
   viOpen (defaultRM, GPIB0::3::INSTR, VI_NULL,VI_NULL, vi);   //This is 
for USB to GPIB adapter

viPrintf(vi, PF4G6S024R, \n);  // Frequencey 
measurement, CH#A, 1Hz res, single measurement,
// Wait to output; Service request at end of meas.  Output at end of Measure.
Sleep(2000);
viPrintf(vi, T, \n);  // Trigger

Sleep(2000);
viScanf(vi, %t, buf); // read results

  printf(DATA string 1: %s\n, buf);  // Print results

  viClose (vi); // Close session
  viClose (defaultRM);

  printf(buf1);
  gets(buf1);//  Program exit after RETURN

}


Thanks to all those who responded last week.
Best regards,
Jerome KC6ENE


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.


Re: [time-nuts] GPIB on HP5382B counter

2009-10-23 Thread Brent Gordon
   I'm out of practice with C, but shouldn't
viScanf(vi, %t, buf);

be

viScanf(vi, %t, buf);

Brent

   Jerome Peters wrote:

I'm still trying to get the HP5328B counter to work with GPIB.  I don't have any
 problems talking, however I can't receive data.
I think the basic (HP/Agilent) hardware/software  are ok, with a similar type of
 program I am able to send/receive to a 34401 Digital Multimeter.
It seems like it should be pretty straight forward to implement but I can't fi
gure out where  I'm going wrong.  There is a test oscillator driving the counter
 at ~5MHz, The Oscillator drifts a bit, so I can see every time it captures a ne
w measurement. The counter is not in talk only mode


___
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.