#include "visa.h"
#define ADD_OFFSET (addr, offs) (((ViPByte)addr) + (offs))
int main(void)
{
ViStatus ViSession ViAddr ViBusAddress ViUInt16 ViUInt16 | status; defaultRM, self; address; offset; addrSpace; value; | /* For checking errors */ /* Communication channels */ /* User pointer */ /* Shared memory offset */ /* Shared memory space */ /* To store register value */ |
/* Begin by initializing the system */
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS) {
/* Error Initializing VISA...exiting */
return -1;
}
/* Open communication with VXI Device at Logical Address 0 */
/* NOTE: For simplicity, we will not show error checking */
status = viOpen(defaultRM, "VXI0::0::INSTR", VI_NULL, VI_NULL, &self);
/* Allocate a portion of the device's memory */
status = viMemAlloc(self, 0x100, &offset);
/* Determine where the shared memory resides */
status = viGetAttribute(self, VI_ATTR_MEM_SPACE, &addrSpace);
status = viMapAddress(self, addrSpace, offset, 0x100, VI_FALSE, VI_NULL, &address);
viPeek16(self, address, &value);
/* Access a different register by manipulating the pointer. */
viPeek16(self, ADD_OFFSET(address, 2), &value);
status = viUnmapAddress(self);
status = viMemFree(self, offset);
/* Close down the system */
status = viClose(self);
status = viClose(defaultRM);
return 0;
} |