Skip to content

Commit

Permalink
Merge pull request #30 from 1a2m3/20221119
Browse files Browse the repository at this point in the history
20221231 update
  • Loading branch information
1a2m3 authored Dec 31, 2022
2 parents f9f2b0e + e686b71 commit 0d50611
Show file tree
Hide file tree
Showing 19 changed files with 1,792 additions and 1,252 deletions.
10 changes: 5 additions & 5 deletions src/SpdReaderWriter/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ public static void Example_FixCRC() {
byte crcMsb = (byte)(crc >> 8); // CRC MSB at 0x7F for 0-125 range or @ 0xFF for 128-253 range

// Compare calculated CRC against SPD data
if (Eeprom.ReadByte(myReader, 0x7e, 1)[0] == crcLsb && Eeprom.ReadByte(myReader, 0x7f, 1)[0] == crcMsb) {
if (Eeprom.ReadByte(myReader, 0x7E, 1)[0] == crcLsb && Eeprom.ReadByte(myReader, 0x7F, 1)[0] == crcMsb) {
// The checksum is correct, do nothing
return;
}
else {
// Write correct values to SPD
Eeprom.UpdateByte(myReader, 0x7e, crcLsb);
Eeprom.UpdateByte(myReader, 0x7f, crcMsb);
Eeprom.UpdateByte(myReader, 0x7E, crcLsb);
Eeprom.UpdateByte(myReader, 0x7F, crcMsb);
}
// Note: you'll have to do the same for 128-253 range, checksum bytes are 0xfe and 0xFF
// Note: you'll have to do the same for 128-253 range, checksum bytes are 0xFE and 0xFF
}

/// <summary>
Expand All @@ -174,7 +174,7 @@ public static void ScanRange() {

bool[] probes = new bool[128];

for (byte i = 0; i < 128; i++) {
for (byte i = 0; i < probes.Length; i++) {
probes[i] = myDevice.ProbeAddress(i);
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/SpdReaderWriter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private static void WriteEeprom() {
string mode = Args[0];
string filePath = Args.Length >= 4 ? Args[3] : "";
bool silent = Args.Length >= 5 && Args[4] == "/silent";
byte i2CAddress = (byte)Int32.Parse(Args[2]);
byte i2CAddress = (byte)int.Parse(Args[2]);

if (filePath.Length < 1) {
throw new Exception("File path is mandatory for write mode.");
Expand Down Expand Up @@ -325,7 +325,7 @@ private static void WriteEeprom() {
private static void ReadEeprom() {
string filePath = Args.Length >= 4 ? Args[3] : "";
bool silent = Args.Length >= 5 && Args[4] == "/silent";
byte i2CAddress = (byte)Int32.Parse(Args[2]);
byte i2CAddress = (byte)int.Parse(Args[2]);
byte[] spdDump = new byte[0];
string name;

Expand Down Expand Up @@ -354,7 +354,7 @@ private static void ReadEeprom() {
}
else {
spdDump = new byte[Smbus.MaxSpdSize];
Smbus.BusNumber = (byte)Int32.Parse(Args[1]);
Smbus.BusNumber = (byte)int.Parse(Args[1]);
Smbus.I2CAddress = i2CAddress;
name = $"{Smbus} ({Smbus.BusNumber})";

Expand Down Expand Up @@ -417,7 +417,7 @@ private static void EnableRswp() {

if (Args.Length == 3) { // Block # was specified
try {
block = new[] { Int32.Parse(Args[2]) };
block = new[] { int.Parse(Args[2]) };
}
catch {
throw new Exception("Block number should be specified in decimal notation.");
Expand Down Expand Up @@ -467,7 +467,7 @@ private static void ScanDevice() {
}
else {
int i = -1;
Int32.TryParse(Args[1], out i);
int.TryParse(Args[1], out i);
if (i != -1) {
addresses = Smbus.Scan();
}
Expand Down Expand Up @@ -506,8 +506,7 @@ private static void Connect() {

// Check FW version
string firmwareFile = Data.BytesToString(Data.Gzip(Resources.Firmware.SpdReaderWriter_ino, Data.GzipMethod.Decompress));
if (Reader.GetFirmwareVersion() <
Int32.Parse(firmwareFile.Split(new string[] { "#define VERSION " }, StringSplitOptions.None)[1].Split(' ')[0].Trim())) {
if (Reader.GetFirmwareVersion() < Arduino.IncludedFirmwareVersion) {
throw new Exception($"The device on port {portName} requires its firmware to be updated.");
}

Expand Down Expand Up @@ -541,7 +540,7 @@ private static void FindDevice() {
/// Looks for Arduino devices
/// </summary>
private static void FindArduino() {
string[] devices = new Arduino(ReaderSettings).Find();
string[] devices = Arduino.Find(ReaderSettings);
if (devices.Length > 0) {
foreach (string portName in devices) {
Console.WriteLine($"Found Arduino on Serial Port: {portName}\n");
Expand Down
Loading

0 comments on commit 0d50611

Please sign in to comment.