Skip to content

Commit cc6700f

Browse files
committed
Corrects asumptions about return values from HAL i2c
Also removes Broadcast, since it's never been implemented. It was disabled from Java and C++ before the season.
1 parent e387257 commit cc6700f

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

WPILib/I2C.cs

+2-16
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ public bool Transaction(byte[] dataToSend, int sendSize, byte[] dataRecieved, in
6363
Array.Copy(dataToSend, sendBuffer, Math.Min(sendSize, dataToSend.Length));
6464
}
6565
byte[] receiveBuffer = new byte[receiveSize];
66-
bool aborted = true;
67-
aborted = HAL_TransactionI2C((byte)m_port, (byte)m_deviceAddress, sendBuffer, (byte)sendSize, receiveBuffer, (byte)receiveSize) != 0;
66+
int status = HAL_TransactionI2C((byte)m_port, (byte)m_deviceAddress, sendBuffer, (byte)sendSize, receiveBuffer, (byte)receiveSize);
6867
if (receiveSize > 0 && dataRecieved != null)
6968
Array.Copy(receiveBuffer, dataRecieved, Math.Min(receiveSize, dataRecieved.Length));
70-
return aborted;
69+
return status < 0;
7170
}
7271
}
7372

@@ -158,19 +157,6 @@ public bool ReadOnly(byte[] buffer, int count)
158157
return retVal < 0;
159158
}
160159

161-
/// <summary>
162-
/// Sends a broadcast write to all devices on the I2C bus.
163-
/// </summary>
164-
/// <remarks>This is currently not implemented.</remarks>
165-
/// <param name="registerAddress">The register to write on all devices on the bus.</param>
166-
/// <param name="data">The value to write to the devices.</param>
167-
/// /// <returns>True if transfer was aborted, otherwise false.</returns>
168-
public bool Broadcast(int registerAddress, int data)
169-
{
170-
//NOTE: Is also not implemented in the Java implementation of WPILib
171-
throw new NotImplementedException();
172-
}
173-
174160
/// <summary>
175161
/// Verify that a device's registers contain expected values.
176162
/// </summary>

0 commit comments

Comments
 (0)