diff --git a/asrl.go b/asrl.go index 35c5dca..0f4a1f8 100644 --- a/asrl.go +++ b/asrl.go @@ -17,9 +17,10 @@ import ( // Device models a serial device and implements the ivi.Driver interface. type Device struct { - EndMark byte - DelayTime time.Duration - port serial.Port + EndMark byte + HWHandshaking bool + DelayTime time.Duration + port serial.Port } // NewDevice opens a serial Device using the given VISA address resource string. @@ -45,9 +46,10 @@ func NewDevice(address string) (*Device, error) { } return &Device{ - port: port, - EndMark: '\n', - DelayTime: 70 * time.Millisecond, + port: port, + HWHandshaking: false, + EndMark: '\n', + DelayTime: 70 * time.Millisecond, }, nil } @@ -74,7 +76,9 @@ func (d *Device) WriteString(s string) (n int, err error) { // Command sends the SCPI/ASCII command to the underlying network connection. A // newline character is automatically added to the end of the string. func (d *Device) Command(format string, a ...any) error { - d.napIfDataSetNotReady() + if d.HWHandshaking { + d.napIfDataSetNotReady() + } cmd := format if a != nil { cmd = fmt.Sprintf(format, a...) diff --git a/examples/keysight/e3631a/main.go b/examples/keysight/e3631a/main.go index 272b0b1..33257f3 100644 --- a/examples/keysight/e3631a/main.go +++ b/examples/keysight/e3631a/main.go @@ -57,6 +57,8 @@ func main() { } defer dev.Close() + dev.HWHandshaking = true + // Query the identification of the function generator. idn, err := dev.Query("*IDN?\r\n") if err != nil && err != io.EOF {