visa_rs/flags.rs
1//!
2//! Defines [`AccessMode`] and [`FlushMode`]
3//!
4//!
5
6use bitflags::bitflags;
7use visa_sys as vs;
8
9bitflags! {
10 /// Used in [`DefaultRM::open`](crate::DefaultRM::open) and [`Instrument::lock`](crate::Instrument::lock), specifies the type of lock requested
11 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
12 pub struct AccessMode: vs::ViAccessMode {
13 const NO_LOCK = vs::VI_NO_LOCK;
14 const EXCLUSIVE_LOCK = vs::VI_EXCLUSIVE_LOCK;
15 const SHARED_LOCK = vs::VI_SHARED_LOCK;
16 const LOAD_CONFIG = vs::VI_LOAD_CONFIG;
17 }
18}
19
20impl Default for AccessMode {
21 fn default() -> Self {
22 Self::NO_LOCK
23 }
24}
25
26bitflags! {
27
28 /// Used in [`Instrument::visa_flush`](crate::Instrument::visa_flush), specifies the action to be taken with flushing the buffer.
29 ///
30 ///It is possible to combine any of these read flags and write flags for different buffers by ORing the flags. However, combining two flags for the same buffer in the same call to viFlush() is illegal.
31 ///
32 ///Notice that when using formatted I/O operations with a session to a Serial device or Ethernet socket, a flush of the formatted I/O buffers also causes the corresponding I/O communication buffers to be flushed. For example, calling viFlush() with VI_WRITE_BUF also flushes the VI_IO_OUT_BUF.
33 ///
34 /// Although you can explicitly flush the buffers by making a call to viFlush(), the buffers are flushed implicitly under some conditions. These conditions vary for the viPrintf() and viScanf() operations.
35 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
36 pub struct FlushMode: vs::ViUInt16 {
37 /// Discard the read buffer contents. If data was present in the read buffer and no END-indicator was present, read from the device until encountering an END indicator (which causes the loss of data). This action resynchronizes the next viScanf() call to read a \<TERMINATED RESPONSE MESSAGE\>. (Refer to the IEEE 488.2 standard.)
38 const READ_BUF = vs::VI_READ_BUF as _ ;
39 /// Discard the read buffer contents (does not perform any I/O to the device).
40 const READ_BUF_DISCARD = vs::VI_READ_BUF_DISCARD as _ ;
41 /// Flush the write buffer by writing all buffered data to the device.
42 const WRITE_BUF = vs::VI_WRITE_BUF as _;
43 /// Discard the write buffer contents (does not perform any I/O to the device).
44 const WRITE_BUF_DISCARD = vs::VI_WRITE_BUF_DISCARD as _;
45 /// Discard the low-level I/O receive buffer contents (same as VI_IO_IN_BUF_DISCARD).
46 const IO_IN_BUF = vs::VI_IO_IN_BUF as _;
47 /// Discard the low-level I/O receive buffer contents (does not perform any I/O to the device).
48 const IO_IN_BUF_DISCARD = vs::VI_IO_IN_BUF_DISCARD as _;
49 /// Flush the low-level I/O transmit buffer by writing all buffered data to the device.
50 const IO_OUT_BUF = vs::VI_IO_OUT_BUF as _;
51 /// Discard the low-level I/O transmit buffer contents (does not perform any I/O to the device).
52 const IO_OUT_BUF_DISCARD = vs::VI_IO_OUT_BUF_DISCARD as _;
53 }
54}
55
56bitflags! {
57 /// Used in [`Instrument::set_buf`](crate::Instrument::set_buf), specifies the type of buffer.
58 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
59 pub struct BufMask: vs::ViUInt16 {
60 /// Formatted I/O read buffer.
61 const READ_BUF = vs::VI_READ_BUF as _ ;
62 /// Formatted I/O write buffer.
63 const WRITE_BUF = vs::VI_WRITE_BUF as _ ;
64 /// Low-level I/O receive buffer.
65 const IO_IN_BUF = vs::VI_IO_IN_BUF as _;
66 /// Low-level I/O transmit buffer.
67 const IO_OUT_BUF = vs::VI_IO_OUT_BUF as _;
68 }
69}