-
Notifications
You must be signed in to change notification settings - Fork 0
/
visa.rkt
852 lines (759 loc) · 31 KB
/
visa.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
#lang racket
(require ffi/unsafe
racket/runtime-path)
(provide vi-open-default-rm
vi-open
vi-write
vi-read
vi-read-stb
vi-read-to-file
vi-close
vi-gpib-control-ren)
(define bufsize 256)
;;; library
(define-runtime-path visa32-library-path
(case (system-type)
[(windows) '(so "visa32")]))
(define visa-lib (ffi-lib visa32-library-path))
;;; operations
;; Asserts the specified interrupt or signal.
(define vi-assert-intr-signal
(get-ffi-obj "viAssertIntrSignal" visa-lib
(_fun (vi : _uint32)
(mode : _int16)
(statusID : _uint32)
-> (ViStatus : _long))))
;; Asserts software or hardware trigger.
(define vi-assert-trigger
(get-ffi-obj "viAssertTrigger" visa-lib
(_fun (vi : _uint32)
(protocol : _uint16)
-> (ViStatus : _long))))
;; Asserts or deasserts the specified utility bus signal.
(define vi-assert-util-signal
(get-ffi-obj "viAssertUtilSignal" visa-lib
(_fun (vi : _uint32)
(line : _uint16)
-> (ViStatus : _long))))
;; Reads data from device or interface through the use of a formatted I/O read buffer.
(define vi-buf-read
(get-ffi-obj "viBufRead" visa-lib
(_fun (vi : _uint32)
(buf : (_ptr o (_array/vector _byte bufsize)))
(count : _uint32)
(retCount : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus buf retCount))))
;; Writes data to a formatted I/O write buffer synchronously.
(define vi-buf-write
(get-ffi-obj "viBufWrite" visa-lib
(_fun (vi : _uint32)
(buf : _string)
(count : _uint32)
(retCount : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus retCount))))
;; Clears a device.
(define vi-clear
(get-ffi-obj "viClear" visa-lib
(_fun (vi : _uint32)
-> (ViStatus : _long))))
;; Closes the specified session, event, or find list.
(define vi-close
(get-ffi-obj "viClose" visa-lib
(_fun (vi : _uint32)
-> (ViStatus : _long))))
;; Disables notification of the specified event type(s) via the specified mechanism(s).
(define vi-disable-event
(get-ffi-obj "viDisableEvent" visa-lib
(_fun (vi : _uint32)
(eventType : _long)
(mechanism : _uint16)
-> (ViStatus : _long))))
;; Discards event occurrences for specified event types and mechanisms in a session.
(define vi-discard-events
(get-ffi-obj "viDiscardEvents" visa-lib
(_fun (vi : _uint32)
(eventType : _long)
(mechanism : _uint16)
-> (ViStatus : _long))))
;; Enables notification of a specified event.
(define vi-enable-event
(get-ffi-obj "viEnableEvent" visa-lib
(_fun (vi : _uint32)
(eventType : _long)
(mechanism : _uint16)
(context : _long)
-> (ViStatus : _long))))
#|
;; Event service handler procedure prototype.
(define vi-event-handler
(get-ffi-obj "viEventHandler" visa-lib
(_fun (vi : _uint32)
(eventType : _long)
(context : _long)
(userHnadle : _void)
-> (ViStatus : _long))))
|#
;; Returns the next resource from the list of resources found during a previous call to viFindRsrc().
(define vi-find-next
(get-ffi-obj "viFindNext" visa-lib
(_fun (findList : _long)
(instrDesc : (_ptr o _string))
-> (ViStatus : _long)
-> (values ViStatus instrDesc))))
;; Queries a VISA system to locate the resources associated with a specified interface.
(define vi-find-rsrc
(get-ffi-obj "viFindRsrc" visa-lib
(_fun (sesn : _uint32)
(expr : _string)
(findList : (_ptr o _long))
(retcnt : (_ptr o _uint32))
(instrDesc : (_ptr o _string))
-> (ViStatus : _long)
-> (values ViStatus findList retcnt instrDesc))))
;; Manually flushes the specified buffers associated with formatted I/O operations and/or serial communication.
(define vi-flush
(get-ffi-obj "viFlush" visa-lib
(_fun (vi : _uint32)
(mask : _uint16)
-> (ViStatus : _long))))
;; Retrieves the state of an attribute.
(define vi-get-attribute
(get-ffi-obj "viGetAttribute" visa-lib
(_fun (vi : _uint32)
(attribute : _uint32)
(attrState : (_ptr o _void))
-> (ViStatus : _long)
-> (values ViStatus attrState))))
;; Write GPIB command bytes on the bus.
(define vi-gpib-command
(get-ffi-obj "viGpibCommand" visa-lib
(_fun (vi : _uint32)
(buf : _string)
(count : _uint32)
(retCount : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus retCount))))
;; Specifies the state of the ATN line and the local active controller state.
(define vi-gpib-control-atn
(get-ffi-obj "viGpibControlATN" visa-lib
(_fun (vi : _uint32)
(mode : _uint16)
-> (ViStatus : _long))))
;; Controls the state of the GPIB Remote Enable (REN) interface line, and optionally the remote/local state of the device.
(define vi-gpib-control-ren
(get-ffi-obj "viGpibControlREN" visa-lib
(_fun (vi : _uint32)
(mode : _uint16)
-> (ViStatus : _long))))
;; Tell the GPIB device at the specified address to become controller in charge (CIC).
(define vi-gpib-pass-control
(get-ffi-obj "viGpibPassControl" visa-lib
(_fun (vi : _uint32)
(primAddr : _uint16)
(secAddr : _uint16)
-> (ViStatus : _long))))
;; Pulse the interface clear line (IFC) for at least 100 microseconds.
(define vi-gpib-send-ifc
(get-ffi-obj "viGpibSendIFC" visa-lib
(_fun (vi : _uint32)
-> (ViStatus : _long))))
;; Reads in an 8-bit, 16-bit, or 32-bit value from the specified memory space and offset.
(define vi-in8
(get-ffi-obj "viIn8" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(val8 : (_ptr o _uint8))
-> (ViStatus : _long)
-> (values ViStatus val8))))
(define vi-in16
(get-ffi-obj "viIn16" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(val16 : (_ptr o _uint16))
-> (ViStatus : _long)
-> (values ViStatus val16))))
(define vi-in32
(get-ffi-obj "viIn32" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(val32 : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus val32))))
;; Installs handlers for event callbacks.
(define vi-install-handler
(get-ffi-obj "viInstallHandler" visa-lib
(_fun (vi : _uint32)
(eventType : _long)
(handler : _long)
(userHandle : (_ptr i _void))
-> (ViStatus : _long))))
;; Establishes an access mode to the specified resource.
(define vi-lock
(get-ffi-obj "viLock" visa-lib
(_fun (vi : _uint32)
(lockType : _long)
(timeout : _uint32)
(requestedKey : _string)
(accessKey : (_ptr o _string))
-> (ViStatus : _long)
-> (values ViStatus accessKey))))
;; Maps the specified memory space into the process’s address space.
(define vi-map-address
(get-ffi-obj "viMapAddress" visa-lib
(_fun (vi : _uint32)
(mapSpace : _uint16)
(mapBase : _long)
(mapSize : _long)
(access : _uint16)
(suggested : (_ptr i _void))
(address : (_ptr o _void))
-> (ViStatus : _long)
-> (values ViStatus address))))
;; Map the specified trigger source line to the specified destination line.
(define vi-map-trigger
(get-ffi-obj "viMapTrigger" visa-lib
(_fun (vi : _uint32)
(trigSrc : _int16)
(trigDest : _int16)
(mode : _uint16)
-> (ViStatus : _long))))
;; Allocates memory from a device’s memory region.
(define vi-mem-alloc
(get-ffi-obj "viMemAlloc" visa-lib
(_fun (vi : _uint32)
(size : _long)
(offset : (_ptr o _long))
-> (ViStatus : _long)
-> (values ViStatus offset))))
;; Frees memory previously allocated using the viMemAlloc() operation.
(define vi-mem-free
(get-ffi-obj "viMemFree" visa-lib
(_fun (vi : _uint32)
(offset : _long)
-> (ViStatus : _long))))
;; Moves a block of data.
(define vi-move
(get-ffi-obj "viMove" visa-lib
(_fun (vi : _uint32)
(srcSpace : _uint16)
(srcOffset : _long)
(srcWidth : _uint16)
(destSpace : _uint16)
(destOffset : _long)
(destWidth : _uint16)
(length : _long)
-> (ViStatus : _long))))
;; Moves a block of data asynchronously.
(define vi-move-async
(get-ffi-obj "viMoveAsync" visa-lib
(_fun (vi : _uint32)
(srcSpace : _uint16)
(srcOffset : _long)
(srcWidth : _uint16)
(destSpace : _uint16)
(destOffset : _long)
(destWidth : _uint16)
(length : _long)
(jobId : (_ptr o _long))
-> (ViStatus : _long)
-> (values ViStatus jobId))))
;; Moves a block of data from the specified address space and offset to local memory.
(define vi-move-in8
(get-ffi-obj "viMoveIn8" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(length : _long)
(buf8 : (_ptr o _uint8))
-> (ViStatus : _long)
-> (values ViStatus buf8))))
(define vi-move-in16
(get-ffi-obj "viMoveIn16" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(length : _long)
(buf16 : (_ptr o _uint16))
-> (ViStatus : _long)
-> (values ViStatus buf16))))
(define vi-move-in32
(get-ffi-obj "viMoveIn32" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(length : _long)
(buf32 : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus buf32))))
;; Moves a block of data from local memory to the specified address space and offset.
(define vi-move-out8
(get-ffi-obj "viMoveOut8" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(length : _long)
(buf8 : _uint8)
-> (ViStatus : _long))))
(define vi-move-out16
(get-ffi-obj "viMoveOut16" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(length : _long)
(buf16 : _uint16)
-> (ViStatus : _long))))
(define vi-move-out32
(get-ffi-obj "viMoveOut32" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(length : _long)
(buf32 : _uint32)
-> (ViStatus : _long))))
;; Opens a session to the specified resource.
(define vi-open
(get-ffi-obj "viOpen" visa-lib
(_fun (sesn : _uint32)
(rsrcName : _string)
(accessMode : _long)
(openTimeout : _uint32)
(vi : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus vi))))
;; This function returns a session to the Default Resource Manager resource.
(define vi-open-default-rm
(get-ffi-obj "viOpenDefaultRM" visa-lib
(_fun (sesn : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus sesn))))
;; Writes an 8-bit, 16-bit, or 32-bit value to the specified memory space and offset.
(define vi-out8
(get-ffi-obj "viOut8" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(val8 : _uint8)
-> (ViStatus : _long))))
(define vi-out16
(get-ffi-obj "viOut16" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(val16 : _uint16)
-> (ViStatus : _long))))
(define vi-out32
(get-ffi-obj "viOut32" visa-lib
(_fun (vi : _uint32)
(space : _uint16)
(offset : _long)
(val32 : _uint32)
-> (ViStatus : _long))))
;; Parse a resource string to get the interface information.
(define vi-parse-rsrc
(get-ffi-obj "viParseRsrc" visa-lib
(_fun (sesn : _uint32)
(rsrcName : _string)
(intfType : (_ptr o _uint16))
(intfNum : (_ptr o _uint16))
-> (ViStatus : _long)
-> (values ViStatus intfType intfNum))))
;; Parse a resource string to get extended interface information.
(define vi-parse-rsrc-ex
(get-ffi-obj "viParseRsrcEx" visa-lib
(_fun (rmSesn : _uint32)
(rsrcName : _string)
(intfType : (_ptr o _uint16))
(intfNum : (_ptr o _uint16))
(rsrcClass : (_ptr o _string))
(expandedUnaliasedName : (_ptr o _string))
(aliasIfExists : (_ptr o _string))
-> (ViStatus : _long)
-> (values ViStatus intfType intfNum
rsrcClass expandedUnaliasedName
aliasIfExists))))
;; Reads an 8-bit, 16-bit, or 32-bit value from the specified address.
(define vi-peek8
(get-ffi-obj "viPeek8" visa-lib
(_fun (vi : _uint32)
(addr : _long)
(val8 : (_ptr o _uint8))
-> (ViStatus : _void)
-> (values ViStatus val8))))
(define vi-peek16
(get-ffi-obj "viPeek16" visa-lib
(_fun (vi : _uint32)
(addr : _long)
(val16 : (_ptr o _uint16))
-> (ViStatus : _void)
-> (values ViStatus val16))))
(define vi-peek32
(get-ffi-obj "viPeek32" visa-lib
(_fun (vi : _uint32)
(addr : _long)
(val32 : (_ptr o _uint32))
-> (ViStatus : _void)
-> (values ViStatus val32))))
;; Writes an 8-bit, 16-bit, or 32-bit value to the specified address.
(define vi-poke8
(get-ffi-obj "viPoke8" visa-lib
(_fun (vi : _uint32)
(addr : (_ptr i _void))
(val8 : _uint32)
-> (ViStatus : _void))))
(define vi-poke16
(get-ffi-obj "viPoke16" visa-lib
(_fun (vi : _uint32)
(addr : (_ptr i _void))
(val16 : _uint32)
-> (ViStatus : _void))))
(define vi-poke32
(get-ffi-obj "viPoke32" visa-lib
(_fun (vi : _uint32)
(addr : (_ptr i _void))
(val32 : _uint32)
-> (ViStatus : _void))))
#|
;; Converts, formats, and sends the parameters (designated by ...) to the device as specified by the format string.
(define vi-printf
(get-ffi-obj "viPrintf" visa-lib
(_fun (vi : _uint32)
(writeFmt : _string)
-> (ViStatus : _long))))
;; Performs a formatted write and read through a single call to an operation.
(define vi-queryf
(get-ffi-obj "viQueryf" visa-lib
(_fun (vi : _uint32)
(writeFmt : _string)
(readFmt : _string)
-> (ViStatus : _long))))
|#
;; Reads data from device or interface synchronously.
(define vi-read (get-ffi-obj "viRead" visa-lib
(_fun (vi : _uint32)
(buf : (_ptr o (_array/vector _byte bufsize)))
(count : _uint32)
(retCount : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus buf retCount))))
;; Reads data from device or interface asynchronously.
(define vi-read-async
(get-ffi-obj "viReadAsync" visa-lib
(_fun (vi : _uint32)
(buf : (_ptr o (_array/vector _byte bufsize)))
(count : _uint32)
(jobId : (_ptr o _long))
-> (ViStatus : _long)
-> (values ViStatus buf jobId))))
;; Reads a status byte of the service request.
(define vi-read-stb
(get-ffi-obj "viReadSTB" visa-lib
(_fun (vi : _uint32)
(status : (_ptr o _uint16))
-> (ViStatus : _long)
-> (values ViStatus status))))
;; Read data synchronously, and store the transferred data in a file.
(define vi-read-to-file
(get-ffi-obj "viReadToFile" visa-lib
(_fun (vi : _uint32)
(fileName : _string)
(count : _uint32)
(retCount : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus retCount))))
#|
;; Reads, converts, and formats data using the format specifier. Stores the formatted data in the parameters (designated by ...).
(define vi-scanf
(get-ffi-obj "viScanf" visa-lib
(_fun (vi : _uint32)
(readFmt : _string)
-> (ViStatus : _long))))
|#
;; Sets the state of an attribute.
(define vi-set-attribute
(get-ffi-obj "viSetAttribute" visa-lib
(_fun (vi : _uint32)
(attribute : _uint32)
(attrState : _long)
-> (ViStatus : _long))))
;; Sets the size for the formatted I/O and/or low-level I/O communication buffer(s).
(define vi-set-buf
(get-ffi-obj "viSetBuf" visa-lib
(_fun (vi : _uint32)
(mask : _uint16)
(size : _uint32)
-> (ViStatus : _long))))
#|
;; Converts, formats, and sends the parameters (designated by ...) to a user-specified buffer as specified by the format string.
(define vi-sprintf
(get-ffi-obj "viSPrintf" visa-lib
(_fun (vi : _uint32)
(buf : (_ptr o _string))
(writeFmt : _string)
-> (ViStatus : _long)
-> (values ViStatus buf))))
;; Reads, converts, and formats data from a user-specified buffer using the format specifier. Stores the formatted data in the parameters (designated by ...).
(define vi-sscanf
(get-ffi-obj "viSScanf" visa-lib
(_fun (vi : _uint32)
(buf : _string)
(readFmt : _string)
-> (ViStatus : _long))))
|#
;; Returns a user-readable description of the status code passed to the operation.
(define vi-status-desc
(get-ffi-obj "viStatusDesc" visa-lib
(_fun (vi : _uint32)
(status : _int32)
(desc : (_ptr o _string))
-> (ViStatus : _long)
-> (values ViStatus desc))))
;; Requests a VISA session to terminate normal execution of an operation.
(define vi-terminate
(get-ffi-obj "viTerminate" visa-lib
(_fun (vi : _uint32)
(degree : _uint16)
(jobId : _long)
-> (ViStatus : _long))))
#|
;; Uninstalls handlers for events.
(define vi-uninstall-handler
(get-ffi-obj "viUninstallHandler" visa-lib
(_fun (vi : _uint32)
(eventType : _long)
(handler : (_ptr i _void))
(userHandle : (_ptr i _void))
-> (ViStatus : _long))))
|#
;; Relinquishes a lock for the specified resource.
(define vi-unlock
(get-ffi-obj "viUnlock" visa-lib
(_fun (vi : _uint32)
-> (ViStatus : _long))))
;; Unmaps memory space previously mapped by viMapAddress().
(define vi-unmap-address
(get-ffi-obj "viUnmapAddress" visa-lib
(_fun (vi : _uint32)
-> (ViStatus : _long))))
;; Undo a previous map from the specified trigger source line to the specified destination line.
(define vi-unmap-trigger
(get-ffi-obj "viUnmapTrigger" visa-lib
(_fun (vi : _uint32)
(trigSrc : _int16)
(trigDest : _int16)
-> (ViStatus : _long))))
;; Performs a USB control pipe transfer from the device.
(define vi-usb-control-in
(get-ffi-obj "viUsbControlIn" visa-lib
(_fun (vi : _uint32)
(bmRequestType : _int16)
(bRequest : _int16)
(wValue : _uint16)
(wIndex : _uint16)
(wLength : _uint16)
(buf : (_ptr o _string))
(retCnt : (_ptr o _uint16))
-> (ViStatus : _long)
-> (values ViStatus buf retCnt))))
;; Performs a USB control pipe transfer to the device.
(define vi-usb-control-out
(get-ffi-obj "viUsbControlOut" visa-lib
(_fun (vi : _uint32)
(bmRequestType : _int16)
(bRequest : _int16)
(wValue : _uint16)
(wIndex : _uint16)
(wLength : _uint16)
(buf : _string)
-> (ViStatus : _long))))
;; Converts, formats, and sends the parameters designated by params to the device or interface as specified by the format string.
(define vi-vprintf
(get-ffi-obj "viVPrintf" visa-lib
(_fun (vi : _uint32)
(writeFmt : _string)
(params : _pointer)
-> (ViStatus : _long))))
;; Performs a formatted write and read through a single call to an operation.
(define vi-vqueryf
(get-ffi-obj "viVQueryf" visa-lib
(_fun (vi : _uint32)
(writeFmt : _string)
(readFmt : _string)
(params : _pointer)
-> (ViStatus : _long))))
;; Reads, converts, and formats data using the format specifier. Stores the formatted data in the parameters designated by params.
(define vi-vscanf
(get-ffi-obj "viVScanf" visa-lib
(_fun (vi : _uint32)
(readFmt : _string)
(params : _pointer)
-> (ViStatus : _long))))
;; Converts, formats, and sends the parameters designated by params to a user-specified buffer as specified by the format string.
(define vi-vs-printf
(get-ffi-obj "viVSPrintf" visa-lib
(_fun (vi : _uint32)
(buf : (_ptr o (_array/vector _byte bufsize)))
(writeFmt : _string)
(params : _pointer)
-> (ViStatus : _long)
-> (values ViStatus buf))))
;; Reads, converts, and formats data from a user-specified buffer using the format specifier. Stores the formatted data in the parameters designated by params.
(define vi-vs-scanf
(get-ffi-obj "viVSScanf" visa-lib
(_fun (vi : _uint32)
(buf : _string)
(readFmt : _string)
(params : _pointer)
-> (ViStatus : _long))))
;; Sends the device a miscellaneous command or query and/or retrieves the response to a previous query.
(define vi-vxi-command-query
(get-ffi-obj "viVxiCommandQuery" visa-lib
(_fun (vi : _uint32)
(mode : _uint16)
(cmd : _uint32)
(response : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus response))))
;; Waits for an occurrence of the specified event for a given session.
(define vi-wait-on-event
(get-ffi-obj "viWaitOnEvent" visa-lib
(_fun (vi : _uint32)
(inEventType : _long)
(timeout : _uint32)
(outEventType : (_ptr o _long))
(outContext : (_ptr o _long))
-> (ViStatus : _long)
-> (values ViStatus outEventType outContext))))
;; Writes data to device or interface synchronously.
(define vi-write
(get-ffi-obj "viWrite" visa-lib
(_fun (vi : _uint32)
(buf : _string)
(count : _uint32)
(retCount : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus retCount))))
;; Writes data to device or interface asynchronously.
(define vi-write-async
(get-ffi-obj "viWriteAsync" visa-lib
(_fun (vi : _uint32)
(buf : _string)
(count : _uint32)
(jobId : (_ptr o _long))
-> (ViStatus : _long)
-> (values ViStatus jobId))))
;; Take data from a file and write it out synchronously.
(define vi-write-from-file
(get-ffi-obj "viWriteFromFile" visa-lib
(_fun (vi : _uint32)
(fileName : _string)
(count : _uint32)
(retCount : (_ptr o _uint32))
-> (ViStatus : _long)
-> (values ViStatus retCount))))
;;; Status Codes
(define vi-success 0)
(define vi-success-event-en #x3FFF0002)
(define vi-success-event-dis #x3FFF0003)
(define vi-success-queue-empty #x3FFF0004)
(define vi-success-term-char #x3FFF0005)
(define vi-success-max-cnt #x3FFF0006)
(define vi-warn-queue-overflow #x3FFF000C)
(define vi-warn-config-nloaded #x3FFF0077)
(define vi-success-dev-npresent #x3FFF007D)
(define vi-success-trig-mapped #x3FFF007E)
(define vi-success-queue-nempty #x3FFF0080)
(define vi-warn-null-object #x3FFF0082)
(define vi-warn-nsup-attr-state #x3FFF0084)
(define vi-warn-unknown-status #x3FFF0085)
(define vi-warn-nsup-buf #x3FFF0088)
(define vi-success-nchain #x3FFF0098)
(define vi-success-nested-shared #x3FFF0099)
(define vi-success-nested-exclusive #x3FFF009A)
(define vi-success-sync #x3FFF009B)
(define vi-warn-ext-func-nimpl #x3FFF00A9)
;;; error codes
(define vi-error-system-error #xBFFF0000)
(define vi-error-inv-object #xBFFF000E)
(define vi-error-rsrc-locked #xBFFF000F)
(define vi-error-inv-expr #xBFFF0010)
(define vi-error-rsrc-nfound #xBFFF0011)
(define vi-error-inv-rsrc-name #xBFFF0012)
(define vi-error-inv-acc-mode #xBFFF0013)
(define vi-error-tmo #xBFFF0015)
(define vi-error-closing-failed #xBFFF0016)
(define vi-error-inv-degree #xBFFF001B)
(define vi-error-inv-job--id #xBFFF001C)
(define vi-error-nsup-attr #xBFFF001D)
(define vi-error-nsup-attr-state #xBFFF001E)
(define vi-error-attr-readonly #xBFFF001F)
(define vi-error-inv-lock-type #xBFFF020)
(define vi-error-inv-access-key #xBFFF0021)
(define vi-error-inv-event #xBFFF0026)
(define vi-error-iv-mech #xBFFF0027)
(define vi-error-hndlr-ninstalled #xBFFF0028)
(define vi-error-inv-hndlr-ref #xBFFF0029)
(define vi-error-inv-context #xBFFF002A)
(define vi-error-queue-overflow #xBFFF002D)
(define vi-error-nenabled #xBFFF002F)
(define vi-error-abort #xBFFF0030)
(define vi-error-raw-wr-prot-viol #xBFFF0034)
(define vi-error-raw-rd-prot-viol #xBFFF0035)
(define vi-error-outp-prot-viol #xBFFF0036)
(define vi-error-inp-prot-viol #xBFFF0037)
(define vi-error-berr #xBFFF0038)
(define vi-error-in-progress #xBFFF0039)
(define vi-error-inv-setup #xBFFF003A)
(define vi-error-queue-error #xBFFF003B)
(define vi-error-alloc #xBFFF003C)
(define vi-error-inv-mask #xBFFF003D)
(define vi-error-io #xBFFF003E)
(define vi-error-inv-fmt #xBFFF003F)
(define vi-error-nsup-fmt #xBFFF0041)
(define vi-error-line-in-use #xBFFF0042)
(define vi-error-nsup-mode #xBFFF0046)
(define vi-error-srq-noccurred #xBFFF004A)
(define vi-error-inv-space #xBFFF004E)
(define vi-error-inv-offset #xBFFF0051)
(define vi-error-inv-width #xBFFF0052)
(define vi-error-nsup-offset #xBFFF0054)
(define vi-error-nsup-var-width #xBFFF0055)
(define vi-error-window-nmapped #xBFFF0057)
(define vi-error-resp-pending #xBFFF0059)
(define vi-error-nlisteners #xBFFF005F)
(define vi-error-ncic #xBFFF0060)
(define vi-error-nsys-cntlr #xBFFF0061)
(define vi-error-nsup-oper #xBFFF0067)
(define vi-error-instr-pending #xBFFF0068)
(define vi-error-asrl-parity #xBFFF006A)
(define vi-error-asrl-framing #xBFFF006B)
(define vi-error-asrl-overrun #xBFFF006C)
(define vi-error-trig-nmapped #xBFFF006E)
(define vi-error-nsup-align-offset #xBFFF0070)
(define vi-error-user-buf #xBFFF0071)
(define vi-error-rsrc-busy #xBfff0072)
(define vi-error-nsup-width #xBFFF0076)
(define vi-error-inv-parameter #xBFFF0078)
(define vi-error-inv-prot #xBFFF0079)
(define vi-error-inv-size #xBFFF007B)
(define vi-error-window-mapped #xBFFF0080)
(define vi-error-nimpl-oper #xBFFF0081)
(define vi-error-inv-length #xBFFF0083)
(define vi-error-inv-mode #xBFFF0091)
(define vi-error-sesn-nlocked #xBFFF009C)
(define vi-error-mem-nshared #xBFFF009D)
(define vi-error-library-nfound #xBFFF009E)
(define vi-error-nsup-intr #xBFFF009F)
(define vi-error-inv-line #xBFFF00A0)
(define vi-error-file-access #xBFFF00A1)
(define vi-error-file-io #xBFFF00A2)
(define vi-error-nsup-line #xBFFF00A3)
(define vi-error-nsup-mech #xBFFF00A4)
(define vi-error-intf-num-nconfig #xBFFF00A5)
(define vi-error-conn-list #xBFFF00A6)
(define vi-error-machine-navail #xBFFF00A7)
(define vi-error-npermission #xBFFF00A8)