Skip to main content

visa_sys/
dynamic_loading.rs

1//! Singleton interface for dynamically loaded VISA library.
2//!
3//! Provides free-standing functions with the same signatures as the static link API,
4//! backed by a global [`LibVisa`] instance that is lazily loaded on first use.
5//!
6//! # Initialization
7//!
8//! The library is automatically loaded with the platform default path on the first
9//! VISA function call. To initialize manually or with a custom path, use
10//! [`load_visa_library`] or [`load_visa_library_from_path`] before any other call.
11//!
12//! # Example
13//!
14//! ```no_run
15//! use visa_sys::*;
16//!
17//! // Option A: let it auto-load on first use
18//! let mut session: ViSession = 0;
19//! let status = unsafe { viOpenDefaultRM(&mut session as ViPSession) };
20//! assert_eq!(status, VI_SUCCESS as ViStatus);
21//!
22//! // Option B: manually initialize before use (with error handling)
23//! if let Err(e) = load_visa_library() {
24//!     eprintln!("VISA not available: {e}");
25//!     return;
26//! }
27//! ```
28//!
29//! # Limitations
30//!
31//! The C *variadic* formatting helpers — `viPrintf`, `viSPrintf`, `viScanf`,
32//! `viSScanf` and `viQueryf` — are **not** exposed as free functions here, because
33//! a variadic C function cannot be called through a `libloading` function pointer.
34//! Use the explicit-`va_list` equivalents instead ([`viVPrintf`], [`viVSPrintf`],
35//! [`viVScanf`], [`viVSScanf`], [`viVQueryf`]). The raw variadic symbols are still
36//! resolved and reachable on the [`LibVisa`] struct via [`get_visa_library`] if you
37//! must call them directly.
38//!
39//! With dynamic loading, a function is only resolved against the library that is
40//! actually loaded. Calling a function that the loaded VISA implementation does not
41//! export panics at the call site (see [`get_visa_library`] to probe availability).
42
43// These free functions are thin FFI passthroughs: their safety is that of the
44// underlying C call, and their argument counts come verbatim from the VISA API.
45#![allow(clippy::missing_safety_doc)]
46#![allow(clippy::too_many_arguments)]
47
48use std::sync::OnceLock;
49
50use super::*;
51
52// `ViVAList` has a platform-dependent shape. On most targets the C `va_list` is a
53// pointer, which bindgen renders as `*mut c_char`. On some ABIs (e.g. x86_64
54// System V and AArch64 Linux) it is a one-element array, which bindgen renders as
55// `[__va_list_tag; 1]` while the matching `LibVisa` method parameter decays to
56// `*mut __va_list_tag`. `VaListArg` bridges both shapes so the free functions can
57// forward a `ViVAList` to the loaded library regardless of how `va_list` is
58// represented on the target, without a fragile per-target `cfg` matrix.
59trait VaListArg {
60    type Ptr;
61    fn va_list_ptr(&mut self) -> Self::Ptr;
62}
63// `va_list` is a pointer (the common case, including all prebindings).
64impl<T> VaListArg for *mut T {
65    type Ptr = *mut T;
66    fn va_list_ptr(&mut self) -> *mut T {
67        *self
68    }
69}
70// `va_list` is a one-element array; the callee expects a pointer to its first
71// element. `self` is borrowed so the array outlives the FFI call.
72impl<T> VaListArg for [T; 1] {
73    type Ptr = *mut T;
74    fn va_list_ptr(&mut self) -> *mut T {
75        self.as_mut_ptr()
76    }
77}
78macro_rules! va_list_arg {
79    ($v:expr) => {
80        $v.va_list_ptr()
81    };
82}
83
84static __LIB_VISA: OnceLock<LibVisa> = OnceLock::new();
85
86fn __default_lib_name() -> &'static str {
87    if cfg!(target_os = "macos") {
88        // `dlopen` does not search the framework directories for a partial
89        // `VISA.framework/VISA` path, so use the absolute install location used
90        // by NI-VISA / Keysight on macOS. Override with load_visa_library_from_path.
91        "/Library/Frameworks/VISA.framework/VISA"
92    } else if cfg!(target_os = "windows") {
93        if cfg!(target_arch = "x86_64") {
94            "visa64.dll"
95        } else {
96            "visa32.dll"
97        }
98    } else {
99        "libvisa.so"
100    }
101}
102
103fn __load_default() -> LibVisa {
104    unsafe {
105        LibVisa::new(__default_lib_name()).unwrap_or_else(|e| {
106            panic!(
107                "failed to load the VISA library from the default path '{}': {e}.\n\
108                 Install a VISA runtime, or call load_visa_library_from_path() with a \
109                 custom path before any other VISA call. To handle a missing library \
110                 without panicking, call load_visa_library() first and check its result.",
111                __default_lib_name()
112            )
113        })
114    }
115}
116
117/// Access the loaded library, auto-loading it from the platform default path on
118/// first use. This is the single entry point the free functions go through.
119///
120/// # Panics
121///
122/// Panics if the library has not been loaded yet and loading from the default
123/// path fails (e.g. no VISA runtime is installed). Call [`load_visa_library`] or
124/// [`load_visa_library_from_path`] beforehand to handle that case gracefully.
125#[inline]
126fn __lib() -> &'static LibVisa {
127    __LIB_VISA.get_or_init(__load_default)
128}
129
130/// Manually load the VISA library from the platform default path.
131///
132/// Returns `Ok(())` if the library was loaded successfully (or was already loaded).
133/// Returns `Err` if loading fails, e.g. because the library is not installed.
134///
135/// This is optional — calling any VISA function will auto-load the library with the
136/// default path. Use this function to detect missing libraries before the first call.
137pub fn load_visa_library() -> Result<(), libloading::Error> {
138    load_visa_library_from_path(__default_lib_name())
139}
140
141/// Manually load the VISA library from a custom path.
142///
143/// Returns `Ok(())` if the library was loaded successfully, or `Err` if loading
144/// fails.
145///
146/// The first successful load wins: if the library was already loaded — including
147/// an auto-load triggered by an earlier VISA call, or a load from a different
148/// path — this is a no-op that returns `Ok(())` and the original instance is
149/// kept. Call this (or [`load_visa_library`]) before any other VISA function to
150/// be sure your path is the one used.
151pub fn load_visa_library_from_path<P: AsRef<std::ffi::OsStr>>(
152    path: P,
153) -> Result<(), libloading::Error> {
154    if __LIB_VISA.get().is_some() {
155        return Ok(());
156    }
157    let lib = unsafe { LibVisa::new(path)? };
158    // If another thread loaded first, that's fine — we drop ours.
159    let _ = __LIB_VISA.set(lib);
160    Ok(())
161}
162
163/// Get a reference to the loaded [`LibVisa`] instance, if available.
164///
165/// Returns `None` if the library has not been loaded yet.
166pub fn get_visa_library() -> Option<&'static LibVisa> {
167    __LIB_VISA.get()
168}
169
170pub unsafe fn viOpenDefaultRM(vi: ViPSession) -> ViStatus {
171    __lib().viOpenDefaultRM(vi)
172}
173
174pub unsafe fn viFindRsrc(
175    sesn: ViSession,
176    expr: ViConstString,
177    vi: ViPFindList,
178    retCnt: ViPUInt32,
179    desc: *mut ViChar,
180) -> ViStatus {
181    __lib().viFindRsrc(sesn, expr, vi, retCnt, desc)
182}
183
184pub unsafe fn viFindNext(vi: ViFindList, desc: *mut ViChar) -> ViStatus {
185    __lib().viFindNext(vi, desc)
186}
187
188pub unsafe fn viParseRsrc(
189    rmSesn: ViSession,
190    rsrcName: ViConstRsrc,
191    intfType: ViPUInt16,
192    intfNum: ViPUInt16,
193) -> ViStatus {
194    __lib().viParseRsrc(rmSesn, rsrcName, intfType, intfNum)
195}
196
197pub unsafe fn viParseRsrcEx(
198    rmSesn: ViSession,
199    rsrcName: ViConstRsrc,
200    intfType: ViPUInt16,
201    intfNum: ViPUInt16,
202    rsrcClass: *mut ViChar,
203    expandedUnaliasedName: *mut ViChar,
204    aliasIfExists: *mut ViChar,
205) -> ViStatus {
206    __lib().viParseRsrcEx(
207        rmSesn,
208        rsrcName,
209        intfType,
210        intfNum,
211        rsrcClass,
212        expandedUnaliasedName,
213        aliasIfExists,
214    )
215}
216
217pub unsafe fn viOpen(
218    sesn: ViSession,
219    name: ViConstRsrc,
220    mode: ViAccessMode,
221    timeout: ViUInt32,
222    vi: ViPSession,
223) -> ViStatus {
224    __lib().viOpen(sesn, name, mode, timeout, vi)
225}
226
227pub unsafe fn viClose(vi: ViObject) -> ViStatus {
228    __lib().viClose(vi)
229}
230
231pub unsafe fn viSetAttribute(vi: ViObject, attrName: ViAttr, attrValue: ViAttrState) -> ViStatus {
232    __lib().viSetAttribute(vi, attrName, attrValue)
233}
234
235pub unsafe fn viGetAttribute(
236    vi: ViObject,
237    attrName: ViAttr,
238    attrValue: *mut ::std::os::raw::c_void,
239) -> ViStatus {
240    __lib().viGetAttribute(vi, attrName, attrValue)
241}
242
243pub unsafe fn viStatusDesc(vi: ViObject, status: ViStatus, desc: *mut ViChar) -> ViStatus {
244    __lib().viStatusDesc(vi, status, desc)
245}
246
247pub unsafe fn viTerminate(vi: ViObject, degree: ViUInt16, jobId: ViJobId) -> ViStatus {
248    __lib().viTerminate(vi, degree, jobId)
249}
250
251pub unsafe fn viLock(
252    vi: ViSession,
253    lockType: ViAccessMode,
254    timeout: ViUInt32,
255    requestedKey: ViConstKeyId,
256    accessKey: *mut ViChar,
257) -> ViStatus {
258    __lib().viLock(vi, lockType, timeout, requestedKey, accessKey)
259}
260
261pub unsafe fn viUnlock(vi: ViSession) -> ViStatus {
262    __lib().viUnlock(vi)
263}
264
265pub unsafe fn viEnableEvent(
266    vi: ViSession,
267    eventType: ViEventType,
268    mechanism: ViUInt16,
269    context: ViEventFilter,
270) -> ViStatus {
271    __lib().viEnableEvent(vi, eventType, mechanism, context)
272}
273
274pub unsafe fn viDisableEvent(
275    vi: ViSession,
276    eventType: ViEventType,
277    mechanism: ViUInt16,
278) -> ViStatus {
279    __lib().viDisableEvent(vi, eventType, mechanism)
280}
281
282pub unsafe fn viDiscardEvents(
283    vi: ViSession,
284    eventType: ViEventType,
285    mechanism: ViUInt16,
286) -> ViStatus {
287    __lib().viDiscardEvents(vi, eventType, mechanism)
288}
289
290pub unsafe fn viWaitOnEvent(
291    vi: ViSession,
292    inEventType: ViEventType,
293    timeout: ViUInt32,
294    outEventType: ViPEventType,
295    outContext: ViPEvent,
296) -> ViStatus {
297    __lib().viWaitOnEvent(vi, inEventType, timeout, outEventType, outContext)
298}
299
300pub unsafe fn viInstallHandler(
301    vi: ViSession,
302    eventType: ViEventType,
303    handler: ViHndlr,
304    userHandle: ViAddr,
305) -> ViStatus {
306    __lib().viInstallHandler(vi, eventType, handler, userHandle)
307}
308
309pub unsafe fn viUninstallHandler(
310    vi: ViSession,
311    eventType: ViEventType,
312    handler: ViHndlr,
313    userHandle: ViAddr,
314) -> ViStatus {
315    __lib().viUninstallHandler(vi, eventType, handler, userHandle)
316}
317
318pub unsafe fn viRead(vi: ViSession, buf: ViPBuf, cnt: ViUInt32, retCnt: ViPUInt32) -> ViStatus {
319    __lib().viRead(vi, buf, cnt, retCnt)
320}
321
322pub unsafe fn viReadAsync(vi: ViSession, buf: ViPBuf, cnt: ViUInt32, jobId: ViPJobId) -> ViStatus {
323    __lib().viReadAsync(vi, buf, cnt, jobId)
324}
325
326pub unsafe fn viReadToFile(
327    vi: ViSession,
328    filename: ViConstString,
329    cnt: ViUInt32,
330    retCnt: ViPUInt32,
331) -> ViStatus {
332    __lib().viReadToFile(vi, filename, cnt, retCnt)
333}
334
335pub unsafe fn viWrite(
336    vi: ViSession,
337    buf: ViConstBuf,
338    cnt: ViUInt32,
339    retCnt: ViPUInt32,
340) -> ViStatus {
341    __lib().viWrite(vi, buf, cnt, retCnt)
342}
343
344pub unsafe fn viWriteAsync(
345    vi: ViSession,
346    buf: ViConstBuf,
347    cnt: ViUInt32,
348    jobId: ViPJobId,
349) -> ViStatus {
350    __lib().viWriteAsync(vi, buf, cnt, jobId)
351}
352
353pub unsafe fn viWriteFromFile(
354    vi: ViSession,
355    filename: ViConstString,
356    cnt: ViUInt32,
357    retCnt: ViPUInt32,
358) -> ViStatus {
359    __lib().viWriteFromFile(vi, filename, cnt, retCnt)
360}
361
362pub unsafe fn viAssertTrigger(vi: ViSession, protocol: ViUInt16) -> ViStatus {
363    __lib().viAssertTrigger(vi, protocol)
364}
365
366pub unsafe fn viReadSTB(vi: ViSession, status: ViPUInt16) -> ViStatus {
367    __lib().viReadSTB(vi, status)
368}
369
370pub unsafe fn viClear(vi: ViSession) -> ViStatus {
371    __lib().viClear(vi)
372}
373
374pub unsafe fn viSetBuf(vi: ViSession, mask: ViUInt16, size: ViUInt32) -> ViStatus {
375    __lib().viSetBuf(vi, mask, size)
376}
377
378pub unsafe fn viFlush(vi: ViSession, mask: ViUInt16) -> ViStatus {
379    __lib().viFlush(vi, mask)
380}
381
382pub unsafe fn viBufWrite(
383    vi: ViSession,
384    buf: ViConstBuf,
385    cnt: ViUInt32,
386    retCnt: ViPUInt32,
387) -> ViStatus {
388    __lib().viBufWrite(vi, buf, cnt, retCnt)
389}
390
391pub unsafe fn viBufRead(vi: ViSession, buf: ViPBuf, cnt: ViUInt32, retCnt: ViPUInt32) -> ViStatus {
392    __lib().viBufRead(vi, buf, cnt, retCnt)
393}
394
395#[allow(unused_mut)]
396pub unsafe fn viVPrintf(vi: ViSession, writeFmt: ViConstString, mut params: ViVAList) -> ViStatus {
397    __lib().viVPrintf(vi, writeFmt, va_list_arg!(params))
398}
399
400#[allow(unused_mut)]
401pub unsafe fn viVSPrintf(
402    vi: ViSession,
403    buf: ViPBuf,
404    writeFmt: ViConstString,
405    mut parms: ViVAList,
406) -> ViStatus {
407    __lib().viVSPrintf(vi, buf, writeFmt, va_list_arg!(parms))
408}
409
410#[allow(unused_mut)]
411pub unsafe fn viVScanf(vi: ViSession, readFmt: ViConstString, mut params: ViVAList) -> ViStatus {
412    __lib().viVScanf(vi, readFmt, va_list_arg!(params))
413}
414
415#[allow(unused_mut)]
416pub unsafe fn viVSScanf(
417    vi: ViSession,
418    buf: ViConstBuf,
419    readFmt: ViConstString,
420    mut parms: ViVAList,
421) -> ViStatus {
422    __lib().viVSScanf(vi, buf, readFmt, va_list_arg!(parms))
423}
424
425#[allow(unused_mut)]
426pub unsafe fn viVQueryf(
427    vi: ViSession,
428    writeFmt: ViConstString,
429    readFmt: ViConstString,
430    mut params: ViVAList,
431) -> ViStatus {
432    __lib().viVQueryf(vi, writeFmt, readFmt, va_list_arg!(params))
433}
434
435pub unsafe fn viIn8(
436    vi: ViSession,
437    space: ViUInt16,
438    offset: ViBusAddress,
439    val8: ViPUInt8,
440) -> ViStatus {
441    __lib().viIn8(vi, space, offset, val8)
442}
443
444pub unsafe fn viOut8(
445    vi: ViSession,
446    space: ViUInt16,
447    offset: ViBusAddress,
448    val8: ViUInt8,
449) -> ViStatus {
450    __lib().viOut8(vi, space, offset, val8)
451}
452
453pub unsafe fn viIn16(
454    vi: ViSession,
455    space: ViUInt16,
456    offset: ViBusAddress,
457    val16: ViPUInt16,
458) -> ViStatus {
459    __lib().viIn16(vi, space, offset, val16)
460}
461
462pub unsafe fn viOut16(
463    vi: ViSession,
464    space: ViUInt16,
465    offset: ViBusAddress,
466    val16: ViUInt16,
467) -> ViStatus {
468    __lib().viOut16(vi, space, offset, val16)
469}
470
471pub unsafe fn viIn32(
472    vi: ViSession,
473    space: ViUInt16,
474    offset: ViBusAddress,
475    val32: ViPUInt32,
476) -> ViStatus {
477    __lib().viIn32(vi, space, offset, val32)
478}
479
480pub unsafe fn viOut32(
481    vi: ViSession,
482    space: ViUInt16,
483    offset: ViBusAddress,
484    val32: ViUInt32,
485) -> ViStatus {
486    __lib().viOut32(vi, space, offset, val32)
487}
488
489pub unsafe fn viIn64(
490    vi: ViSession,
491    space: ViUInt16,
492    offset: ViBusAddress,
493    val64: ViPUInt64,
494) -> ViStatus {
495    __lib().viIn64(vi, space, offset, val64)
496}
497
498pub unsafe fn viOut64(
499    vi: ViSession,
500    space: ViUInt16,
501    offset: ViBusAddress,
502    val64: ViUInt64,
503) -> ViStatus {
504    __lib().viOut64(vi, space, offset, val64)
505}
506
507pub unsafe fn viIn8Ex(
508    vi: ViSession,
509    space: ViUInt16,
510    offset: ViBusAddress64,
511    val8: ViPUInt8,
512) -> ViStatus {
513    __lib().viIn8Ex(vi, space, offset, val8)
514}
515
516pub unsafe fn viOut8Ex(
517    vi: ViSession,
518    space: ViUInt16,
519    offset: ViBusAddress64,
520    val8: ViUInt8,
521) -> ViStatus {
522    __lib().viOut8Ex(vi, space, offset, val8)
523}
524
525pub unsafe fn viIn16Ex(
526    vi: ViSession,
527    space: ViUInt16,
528    offset: ViBusAddress64,
529    val16: ViPUInt16,
530) -> ViStatus {
531    __lib().viIn16Ex(vi, space, offset, val16)
532}
533
534pub unsafe fn viOut16Ex(
535    vi: ViSession,
536    space: ViUInt16,
537    offset: ViBusAddress64,
538    val16: ViUInt16,
539) -> ViStatus {
540    __lib().viOut16Ex(vi, space, offset, val16)
541}
542
543pub unsafe fn viIn32Ex(
544    vi: ViSession,
545    space: ViUInt16,
546    offset: ViBusAddress64,
547    val32: ViPUInt32,
548) -> ViStatus {
549    __lib().viIn32Ex(vi, space, offset, val32)
550}
551
552pub unsafe fn viOut32Ex(
553    vi: ViSession,
554    space: ViUInt16,
555    offset: ViBusAddress64,
556    val32: ViUInt32,
557) -> ViStatus {
558    __lib().viOut32Ex(vi, space, offset, val32)
559}
560
561pub unsafe fn viIn64Ex(
562    vi: ViSession,
563    space: ViUInt16,
564    offset: ViBusAddress64,
565    val64: ViPUInt64,
566) -> ViStatus {
567    __lib().viIn64Ex(vi, space, offset, val64)
568}
569
570pub unsafe fn viOut64Ex(
571    vi: ViSession,
572    space: ViUInt16,
573    offset: ViBusAddress64,
574    val64: ViUInt64,
575) -> ViStatus {
576    __lib().viOut64Ex(vi, space, offset, val64)
577}
578
579pub unsafe fn viMoveIn8(
580    vi: ViSession,
581    space: ViUInt16,
582    offset: ViBusAddress,
583    length: ViBusSize,
584    buf8: ViAUInt8,
585) -> ViStatus {
586    __lib().viMoveIn8(vi, space, offset, length, buf8)
587}
588
589pub unsafe fn viMoveOut8(
590    vi: ViSession,
591    space: ViUInt16,
592    offset: ViBusAddress,
593    length: ViBusSize,
594    buf8: ViAUInt8,
595) -> ViStatus {
596    __lib().viMoveOut8(vi, space, offset, length, buf8)
597}
598
599pub unsafe fn viMoveIn16(
600    vi: ViSession,
601    space: ViUInt16,
602    offset: ViBusAddress,
603    length: ViBusSize,
604    buf16: ViAUInt16,
605) -> ViStatus {
606    __lib().viMoveIn16(vi, space, offset, length, buf16)
607}
608
609pub unsafe fn viMoveOut16(
610    vi: ViSession,
611    space: ViUInt16,
612    offset: ViBusAddress,
613    length: ViBusSize,
614    buf16: ViAUInt16,
615) -> ViStatus {
616    __lib().viMoveOut16(vi, space, offset, length, buf16)
617}
618
619pub unsafe fn viMoveIn32(
620    vi: ViSession,
621    space: ViUInt16,
622    offset: ViBusAddress,
623    length: ViBusSize,
624    buf32: ViAUInt32,
625) -> ViStatus {
626    __lib().viMoveIn32(vi, space, offset, length, buf32)
627}
628
629pub unsafe fn viMoveOut32(
630    vi: ViSession,
631    space: ViUInt16,
632    offset: ViBusAddress,
633    length: ViBusSize,
634    buf32: ViAUInt32,
635) -> ViStatus {
636    __lib().viMoveOut32(vi, space, offset, length, buf32)
637}
638
639pub unsafe fn viMoveIn64(
640    vi: ViSession,
641    space: ViUInt16,
642    offset: ViBusAddress,
643    length: ViBusSize,
644    buf64: ViAUInt64,
645) -> ViStatus {
646    __lib().viMoveIn64(vi, space, offset, length, buf64)
647}
648
649pub unsafe fn viMoveOut64(
650    vi: ViSession,
651    space: ViUInt16,
652    offset: ViBusAddress,
653    length: ViBusSize,
654    buf64: ViAUInt64,
655) -> ViStatus {
656    __lib().viMoveOut64(vi, space, offset, length, buf64)
657}
658
659pub unsafe fn viMoveIn8Ex(
660    vi: ViSession,
661    space: ViUInt16,
662    offset: ViBusAddress64,
663    length: ViBusSize,
664    buf8: ViAUInt8,
665) -> ViStatus {
666    __lib().viMoveIn8Ex(vi, space, offset, length, buf8)
667}
668
669pub unsafe fn viMoveOut8Ex(
670    vi: ViSession,
671    space: ViUInt16,
672    offset: ViBusAddress64,
673    length: ViBusSize,
674    buf8: ViAUInt8,
675) -> ViStatus {
676    __lib().viMoveOut8Ex(vi, space, offset, length, buf8)
677}
678
679pub unsafe fn viMoveIn16Ex(
680    vi: ViSession,
681    space: ViUInt16,
682    offset: ViBusAddress64,
683    length: ViBusSize,
684    buf16: ViAUInt16,
685) -> ViStatus {
686    __lib().viMoveIn16Ex(vi, space, offset, length, buf16)
687}
688
689pub unsafe fn viMoveOut16Ex(
690    vi: ViSession,
691    space: ViUInt16,
692    offset: ViBusAddress64,
693    length: ViBusSize,
694    buf16: ViAUInt16,
695) -> ViStatus {
696    __lib().viMoveOut16Ex(vi, space, offset, length, buf16)
697}
698
699pub unsafe fn viMoveIn32Ex(
700    vi: ViSession,
701    space: ViUInt16,
702    offset: ViBusAddress64,
703    length: ViBusSize,
704    buf32: ViAUInt32,
705) -> ViStatus {
706    __lib().viMoveIn32Ex(vi, space, offset, length, buf32)
707}
708
709pub unsafe fn viMoveOut32Ex(
710    vi: ViSession,
711    space: ViUInt16,
712    offset: ViBusAddress64,
713    length: ViBusSize,
714    buf32: ViAUInt32,
715) -> ViStatus {
716    __lib().viMoveOut32Ex(vi, space, offset, length, buf32)
717}
718
719pub unsafe fn viMoveIn64Ex(
720    vi: ViSession,
721    space: ViUInt16,
722    offset: ViBusAddress64,
723    length: ViBusSize,
724    buf64: ViAUInt64,
725) -> ViStatus {
726    __lib().viMoveIn64Ex(vi, space, offset, length, buf64)
727}
728
729pub unsafe fn viMoveOut64Ex(
730    vi: ViSession,
731    space: ViUInt16,
732    offset: ViBusAddress64,
733    length: ViBusSize,
734    buf64: ViAUInt64,
735) -> ViStatus {
736    __lib().viMoveOut64Ex(vi, space, offset, length, buf64)
737}
738
739pub unsafe fn viMove(
740    vi: ViSession,
741    srcSpace: ViUInt16,
742    srcOffset: ViBusAddress,
743    srcWidth: ViUInt16,
744    destSpace: ViUInt16,
745    destOffset: ViBusAddress,
746    destWidth: ViUInt16,
747    srcLength: ViBusSize,
748) -> ViStatus {
749    __lib().viMove(
750        vi, srcSpace, srcOffset, srcWidth, destSpace, destOffset, destWidth, srcLength,
751    )
752}
753
754pub unsafe fn viMoveAsync(
755    vi: ViSession,
756    srcSpace: ViUInt16,
757    srcOffset: ViBusAddress,
758    srcWidth: ViUInt16,
759    destSpace: ViUInt16,
760    destOffset: ViBusAddress,
761    destWidth: ViUInt16,
762    srcLength: ViBusSize,
763    jobId: ViPJobId,
764) -> ViStatus {
765    __lib().viMoveAsync(
766        vi, srcSpace, srcOffset, srcWidth, destSpace, destOffset, destWidth, srcLength, jobId,
767    )
768}
769
770pub unsafe fn viMoveEx(
771    vi: ViSession,
772    srcSpace: ViUInt16,
773    srcOffset: ViBusAddress64,
774    srcWidth: ViUInt16,
775    destSpace: ViUInt16,
776    destOffset: ViBusAddress64,
777    destWidth: ViUInt16,
778    srcLength: ViBusSize,
779) -> ViStatus {
780    __lib().viMoveEx(
781        vi, srcSpace, srcOffset, srcWidth, destSpace, destOffset, destWidth, srcLength,
782    )
783}
784
785pub unsafe fn viMoveAsyncEx(
786    vi: ViSession,
787    srcSpace: ViUInt16,
788    srcOffset: ViBusAddress64,
789    srcWidth: ViUInt16,
790    destSpace: ViUInt16,
791    destOffset: ViBusAddress64,
792    destWidth: ViUInt16,
793    srcLength: ViBusSize,
794    jobId: ViPJobId,
795) -> ViStatus {
796    __lib().viMoveAsyncEx(
797        vi, srcSpace, srcOffset, srcWidth, destSpace, destOffset, destWidth, srcLength, jobId,
798    )
799}
800
801pub unsafe fn viMapAddress(
802    vi: ViSession,
803    mapSpace: ViUInt16,
804    mapOffset: ViBusAddress,
805    mapSize: ViBusSize,
806    access: ViBoolean,
807    suggested: ViAddr,
808    address: ViPAddr,
809) -> ViStatus {
810    __lib().viMapAddress(vi, mapSpace, mapOffset, mapSize, access, suggested, address)
811}
812
813pub unsafe fn viUnmapAddress(vi: ViSession) -> ViStatus {
814    __lib().viUnmapAddress(vi)
815}
816
817pub unsafe fn viMapAddressEx(
818    vi: ViSession,
819    mapSpace: ViUInt16,
820    mapOffset: ViBusAddress64,
821    mapSize: ViBusSize,
822    access: ViBoolean,
823    suggested: ViAddr,
824    address: ViPAddr,
825) -> ViStatus {
826    __lib().viMapAddressEx(vi, mapSpace, mapOffset, mapSize, access, suggested, address)
827}
828
829pub unsafe fn viPeek8(vi: ViSession, address: ViAddr, val8: ViPUInt8) {
830    __lib().viPeek8(vi, address, val8)
831}
832
833pub unsafe fn viPoke8(vi: ViSession, address: ViAddr, val8: ViUInt8) {
834    __lib().viPoke8(vi, address, val8)
835}
836
837pub unsafe fn viPeek16(vi: ViSession, address: ViAddr, val16: ViPUInt16) {
838    __lib().viPeek16(vi, address, val16)
839}
840
841pub unsafe fn viPoke16(vi: ViSession, address: ViAddr, val16: ViUInt16) {
842    __lib().viPoke16(vi, address, val16)
843}
844
845pub unsafe fn viPeek32(vi: ViSession, address: ViAddr, val32: ViPUInt32) {
846    __lib().viPeek32(vi, address, val32)
847}
848
849pub unsafe fn viPoke32(vi: ViSession, address: ViAddr, val32: ViUInt32) {
850    __lib().viPoke32(vi, address, val32)
851}
852
853pub unsafe fn viPeek64(vi: ViSession, address: ViAddr, val64: ViPUInt64) {
854    __lib().viPeek64(vi, address, val64)
855}
856
857pub unsafe fn viPoke64(vi: ViSession, address: ViAddr, val64: ViUInt64) {
858    __lib().viPoke64(vi, address, val64)
859}
860
861pub unsafe fn viMemAlloc(vi: ViSession, size: ViBusSize, offset: ViPBusAddress) -> ViStatus {
862    __lib().viMemAlloc(vi, size, offset)
863}
864
865pub unsafe fn viMemFree(vi: ViSession, offset: ViBusAddress) -> ViStatus {
866    __lib().viMemFree(vi, offset)
867}
868
869pub unsafe fn viMemAllocEx(vi: ViSession, size: ViBusSize, offset: ViPBusAddress64) -> ViStatus {
870    __lib().viMemAllocEx(vi, size, offset)
871}
872
873pub unsafe fn viMemFreeEx(vi: ViSession, offset: ViBusAddress64) -> ViStatus {
874    __lib().viMemFreeEx(vi, offset)
875}
876
877pub unsafe fn viGpibControlREN(vi: ViSession, mode: ViUInt16) -> ViStatus {
878    __lib().viGpibControlREN(vi, mode)
879}
880
881pub unsafe fn viGpibControlATN(vi: ViSession, mode: ViUInt16) -> ViStatus {
882    __lib().viGpibControlATN(vi, mode)
883}
884
885pub unsafe fn viGpibSendIFC(vi: ViSession) -> ViStatus {
886    __lib().viGpibSendIFC(vi)
887}
888
889pub unsafe fn viGpibCommand(
890    vi: ViSession,
891    cmd: ViConstBuf,
892    cnt: ViUInt32,
893    retCnt: ViPUInt32,
894) -> ViStatus {
895    __lib().viGpibCommand(vi, cmd, cnt, retCnt)
896}
897
898pub unsafe fn viGpibPassControl(vi: ViSession, primAddr: ViUInt16, secAddr: ViUInt16) -> ViStatus {
899    __lib().viGpibPassControl(vi, primAddr, secAddr)
900}
901
902pub unsafe fn viVxiCommandQuery(
903    vi: ViSession,
904    mode: ViUInt16,
905    cmd: ViUInt32,
906    response: ViPUInt32,
907) -> ViStatus {
908    __lib().viVxiCommandQuery(vi, mode, cmd, response)
909}
910
911pub unsafe fn viAssertUtilSignal(vi: ViSession, line: ViUInt16) -> ViStatus {
912    __lib().viAssertUtilSignal(vi, line)
913}
914
915pub unsafe fn viAssertIntrSignal(vi: ViSession, mode: ViInt16, statusID: ViUInt32) -> ViStatus {
916    __lib().viAssertIntrSignal(vi, mode, statusID)
917}
918
919pub unsafe fn viMapTrigger(
920    vi: ViSession,
921    trigSrc: ViInt16,
922    trigDest: ViInt16,
923    mode: ViUInt16,
924) -> ViStatus {
925    __lib().viMapTrigger(vi, trigSrc, trigDest, mode)
926}
927
928pub unsafe fn viUnmapTrigger(vi: ViSession, trigSrc: ViInt16, trigDest: ViInt16) -> ViStatus {
929    __lib().viUnmapTrigger(vi, trigSrc, trigDest)
930}
931
932pub unsafe fn viUsbControlOut(
933    vi: ViSession,
934    bmRequestType: ViInt16,
935    bRequest: ViInt16,
936    wValue: ViUInt16,
937    wIndex: ViUInt16,
938    wLength: ViUInt16,
939    buf: ViConstBuf,
940) -> ViStatus {
941    __lib().viUsbControlOut(vi, bmRequestType, bRequest, wValue, wIndex, wLength, buf)
942}
943
944pub unsafe fn viUsbControlIn(
945    vi: ViSession,
946    bmRequestType: ViInt16,
947    bRequest: ViInt16,
948    wValue: ViUInt16,
949    wIndex: ViUInt16,
950    wLength: ViUInt16,
951    buf: ViPBuf,
952    retCnt: ViPUInt16,
953) -> ViStatus {
954    __lib().viUsbControlIn(
955        vi,
956        bmRequestType,
957        bRequest,
958        wValue,
959        wIndex,
960        wLength,
961        buf,
962        retCnt,
963    )
964}
965
966pub unsafe fn viPxiReserveTriggers(
967    vi: ViSession,
968    cnt: ViInt16,
969    trigBuses: ViAInt16,
970    trigLines: ViAInt16,
971    failureIndex: ViPInt16,
972) -> ViStatus {
973    __lib().viPxiReserveTriggers(vi, cnt, trigBuses, trigLines, failureIndex)
974}