Skip to content

Commit 0d50611

Browse files
authored
Merge pull request #30 from 1a2m3/20221119
20221231 update
2 parents f9f2b0e + e686b71 commit 0d50611

File tree

19 files changed

+1792
-1252
lines changed

19 files changed

+1792
-1252
lines changed

src/SpdReaderWriter/Example.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ public static void Example_FixCRC() {
142142
byte crcMsb = (byte)(crc >> 8); // CRC MSB at 0x7F for 0-125 range or @ 0xFF for 128-253 range
143143

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

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

175175
bool[] probes = new bool[128];
176176

177-
for (byte i = 0; i < 128; i++) {
177+
for (byte i = 0; i < probes.Length; i++) {
178178
probes[i] = myDevice.ProbeAddress(i);
179179
}
180180
}

src/SpdReaderWriter/Program.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private static void WriteEeprom() {
255255
string mode = Args[0];
256256
string filePath = Args.Length >= 4 ? Args[3] : "";
257257
bool silent = Args.Length >= 5 && Args[4] == "/silent";
258-
byte i2CAddress = (byte)Int32.Parse(Args[2]);
258+
byte i2CAddress = (byte)int.Parse(Args[2]);
259259

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

@@ -354,7 +354,7 @@ private static void ReadEeprom() {
354354
}
355355
else {
356356
spdDump = new byte[Smbus.MaxSpdSize];
357-
Smbus.BusNumber = (byte)Int32.Parse(Args[1]);
357+
Smbus.BusNumber = (byte)int.Parse(Args[1]);
358358
Smbus.I2CAddress = i2CAddress;
359359
name = $"{Smbus} ({Smbus.BusNumber})";
360360

@@ -417,7 +417,7 @@ private static void EnableRswp() {
417417

418418
if (Args.Length == 3) { // Block # was specified
419419
try {
420-
block = new[] { Int32.Parse(Args[2]) };
420+
block = new[] { int.Parse(Args[2]) };
421421
}
422422
catch {
423423
throw new Exception("Block number should be specified in decimal notation.");
@@ -467,7 +467,7 @@ private static void ScanDevice() {
467467
}
468468
else {
469469
int i = -1;
470-
Int32.TryParse(Args[1], out i);
470+
int.TryParse(Args[1], out i);
471471
if (i != -1) {
472472
addresses = Smbus.Scan();
473473
}
@@ -506,8 +506,7 @@ private static void Connect() {
506506

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

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

0 commit comments

Comments
 (0)