Skip to content

Commit

Permalink
Arduino: nicer initialization of command-answer variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicost committed Oct 28, 2024
1 parent 3d8ab19 commit a267dc1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions DeviceAdapters/Arduino/Arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,7 @@ bool CArduinoInput::Busy()
return false;
}


int CArduinoInput::GetDigitalInput(long* state)
{
const std::lock_guard<std::mutex> lock(hub_->GetLock());
Expand Down Expand Up @@ -1648,9 +1649,7 @@ int CArduinoInput::OnAnalogInput(MM::PropertyBase* pProp, MM::ActionType eAct, l
{
const std::lock_guard<std::mutex> lock(hub_->GetLock());

unsigned char command[2];
command[0] = 41;
command[1] = (unsigned char) channel;
unsigned char command[2] = { 41, (unsigned char) channel };

int ret = hub_->WriteToComPortH((const unsigned char*) command, 2);
if (ret != DEVICE_OK)
Expand Down Expand Up @@ -1689,7 +1688,7 @@ int CArduinoInput::SetPullUp(int pin, int state)
if (ret != DEVICE_OK)
return ret;

unsigned char answer[3];
unsigned char answer[3] = { 0, 0, 0 };
ret = ReadNBytes(hub_, 3, answer);
if (ret != DEVICE_OK)
return ret;
Expand Down

0 comments on commit a267dc1

Please sign in to comment.