Skip to content

Commit f3400d1

Browse files
author
dcyoung
committed
Added check for bIsScanning before sending commands. closes #1
1 parent 5245eb5 commit f3400d1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Sweep/Sweep.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Sweep::~Sweep()
1111

1212
bool Sweep::startScanning()
1313
{
14+
if (bIsScanning)
15+
return false;
16+
1417
_writeCommand(_DATA_ACQUISITION_START);
1518
// wait for the receipt (possible timeout)
1619
if (_readResponseHeader())
@@ -65,6 +68,9 @@ bool Sweep::getReading(ScanPacket &reading)
6568

6669
int32_t Sweep::getMotorSpeed()
6770
{
71+
if (bIsScanning)
72+
return false;
73+
6874
_writeCommand(_MOTOR_INFORMATION);
6975
if (_readResponseInfoSetting())
7076
{
@@ -77,6 +83,9 @@ int32_t Sweep::getMotorSpeed()
7783

7884
bool Sweep::setMotorSpeed(const uint8_t motorSpeedCode[2])
7985
{
86+
if (bIsScanning)
87+
return false;
88+
8089
_writeCommandWithArgument(_MOTOR_SPEED_ADJUST, motorSpeedCode);
8190
// wait for the receipt (possible timeout)
8291
if (_readResponseParam())
@@ -89,6 +98,9 @@ bool Sweep::setMotorSpeed(const uint8_t motorSpeedCode[2])
8998

9099
int32_t Sweep::getSampleRate()
91100
{
101+
if (bIsScanning)
102+
return false;
103+
92104
_writeCommand(_SAMPLE_RATE_INFORMATION);
93105
if (_readResponseInfoSetting())
94106
{
@@ -111,6 +123,9 @@ int32_t Sweep::getSampleRate()
111123

112124
bool Sweep::setSampleRate(const uint8_t sampleRateCode[2])
113125
{
126+
if (bIsScanning)
127+
return false;
128+
114129
_writeCommandWithArgument(_SAMPLE_RATE_ADJUST, sampleRateCode);
115130
// wait for the receipt (possible timeout)
116131
if (_readResponseParam())

0 commit comments

Comments
 (0)