@@ -10,25 +10,13 @@ class Example {
1010 /// <summary>
1111 /// Serial port settings
1212 /// </summary>
13- public static Device . SerialPortSettings readerSettings = new Device . SerialPortSettings (
13+ public static SerialDevice . SerialPortSettings readerSettings = new SerialDevice . SerialPortSettings (
1414 // Baud rate
1515 115200 ,
1616 // Enable DTR
1717 true ,
1818 // Enable RTS
1919 true ,
20- // Data bits
21- 8 ,
22- // Handshake
23- Handshake . None ,
24- // New line
25- "\n " ,
26- // Parity
27- Parity . None ,
28- // Stop bits
29- StopBits . One ,
30- // Use event handler
31- true ,
3220 // Response timeout (sec.)
3321 10 ) ;
3422
@@ -42,7 +30,7 @@ class Example {
4230 /// </summary>
4331 public static void Example_BasicUse ( ) {
4432 // Initialize the device
45- Device myDevice = new Device ( readerSettings , portName ) ;
33+ SerialDevice myDevice = new SerialDevice ( readerSettings , portName ) ;
4634 //myDevice.Connect();
4735
4836 // Test if the device responds (optional)
@@ -59,7 +47,7 @@ public static void Example_BasicUse() {
5947 myDevice . SpdSize = Ram . SpdSize . DDR4 ;
6048
6149 // The device can also be initialized in one line, like so:
62- Device myOtherDevice = new Device ( readerSettings , portName , 80 , Ram . SpdSize . DDR4 ) ;
50+ SerialDevice myOtherDevice = new SerialDevice ( readerSettings , portName , 80 , Ram . SpdSize . DDR4 ) ;
6351
6452 // Read first byte at offset 0
6553 byte firstByte = Eeprom . ReadByte ( myDevice , 0 ) ;
@@ -84,7 +72,7 @@ public static void Example_BasicUse() {
8472 /// Test an unreachable device to make sure all functions properly return false
8573 /// </summary>
8674 public static void Example_TestNonConnectableDevice ( ) {
87- Device UnreachableDevice = new Device ( readerSettings , "COM666" ) ;
75+ SerialDevice UnreachableDevice = new SerialDevice ( readerSettings , "COM666" ) ;
8876 UnreachableDevice . I2CAddress = 0x50 ;
8977 if ( UnreachableDevice . IsConnected ) {
9078 // This won't be reached
@@ -97,12 +85,12 @@ public static void Example_TestNonConnectableDevice() {
9785 /// </summary>
9886 public static void Example_TestRealDevice ( ) {
9987 // Test a real device
100- Device RealDevice = new Device ( readerSettings , portName ) ;
88+ SerialDevice RealDevice = new SerialDevice ( readerSettings , portName ) ;
10189 RealDevice . Test ( ) ; //true
10290 RealDevice . Scan ( ) ; //{ 80 }
10391
10492 // Test a real device
105- Device MyReader = new Device ( readerSettings , portName , 0x50 , Ram . SpdSize . DDR4 ) ;
93+ SerialDevice MyReader = new SerialDevice ( readerSettings , portName , 0x50 , Ram . SpdSize . DDR4 ) ;
10694 MyReader . Test ( ) ; //true
10795 }
10896
@@ -111,8 +99,8 @@ public static void Example_TestRealDevice() {
11199 /// </summary>
112100 public static void Example_DuplicateRam ( ) {
113101 // Copy SPD contents from one DIMM to another
114- Device source = new Device ( readerSettings , "COM1" , 80 , Ram . SpdSize . DDR4 ) ;
115- Device destination = new Device ( readerSettings , "COM4" , 82 , source . SpdSize ) ;
102+ SerialDevice source = new SerialDevice ( readerSettings , "COM1" , 80 , Ram . SpdSize . DDR4 ) ;
103+ SerialDevice destination = new SerialDevice ( readerSettings , "COM4" , 82 , source . SpdSize ) ;
116104
117105 for ( ushort i = 0 ; i < ( int ) source . SpdSize ; i ++ ) {
118106 Eeprom . WriteByte ( destination , i , Eeprom . ReadByte ( source , i ) ) ;
@@ -131,17 +119,17 @@ public static void Example_DuplicateRam() {
131119 /// </summary>
132120 public static void Example_FixCRC ( ) {
133121
134- Device MyReader = new Device ( readerSettings , portName , 0x52 , Ram . SpdSize . DDR4 ) ;
122+ SerialDevice MyReader = new SerialDevice ( readerSettings , portName , 0x52 , Ram . SpdSize . DDR4 ) ;
135123
136124 // Read first 126 bytes
137125 byte [ ] spdHeader = Eeprom . ReadByte ( MyReader , 0 , 126 ) ;
138126
139127 // Calculate CRC
140- ushort crc = Spd . Crc16 ( spdHeader , 0x1021 ) ;
128+ ushort crc = Data . Crc16 ( spdHeader , 0x1021 ) ;
141129
142130 // Get LSB (byte 127) and MSB (byte 128)
143- byte CrcLsb = ( byte ) ( crc & 0xff ) ; // CRC LSB at 0x7e for 0-125 range or @ 0xfe for 128-253 range
144- byte CrcMsb = ( byte ) ( crc >> 8 ) ; // CRC MSB at 0x7f for 0-125 range or @ 0xff for 128-253 range
131+ byte CrcLsb = ( byte ) ( crc & 0xFF ) ; // CRC LSB at 0x7E for 0-125 range or @ 0xFE for 128-253 range
132+ byte CrcMsb = ( byte ) ( crc >> 8 ) ; // CRC MSB at 0x7F for 0-125 range or @ 0xFF for 128-253 range
145133
146134 // Compare calculated CRC against SPD data
147135 if ( Eeprom . ReadByte ( MyReader , 0x7e , 1 ) [ 0 ] == CrcLsb && Eeprom . ReadByte ( MyReader , 0x7f , 1 ) [ 0 ] == CrcMsb ) {
@@ -153,16 +141,16 @@ public static void Example_FixCRC() {
153141 Eeprom . UpdateByte ( MyReader , 0x7e , CrcLsb ) ;
154142 Eeprom . UpdateByte ( MyReader , 0x7f , CrcMsb ) ;
155143 }
156- // Note: you'll have to do the same for 128-253 range, checksum bytes are 0xfe and 0xff
144+ // Note: you'll have to do the same for 128-253 range, checksum bytes are 0xfe and 0xFF
157145 }
158146
159147 /// <summary>
160- /// Erase SPD contents (fill with 0xff 's)
148+ /// Erase SPD contents (fill with 0xFF 's)
161149 /// </summary>
162150 public static void Example_EraseSPD ( ) {
163- Device MyReader = new Device ( readerSettings , portName , 0x50 , Ram . SpdSize . DDR4 ) ;
151+ SerialDevice MyReader = new SerialDevice ( readerSettings , portName , 0x50 , Ram . SpdSize . DDR4 ) ;
164152 for ( ushort i = 0 ; i <= ( int ) MyReader . SpdSize ; i ++ ) {
165- Eeprom . UpdateByte ( MyReader , i , 0xff ) ;
153+ Eeprom . UpdateByte ( MyReader , i , 0xFF ) ;
166154 Console . WriteLine ( i . ToString ( ) ) ;
167155 }
168156 }
@@ -172,7 +160,7 @@ public static void Example_EraseSPD() {
172160 /// </summary>
173161 public static void ScanRange ( ) {
174162
175- Device myDevice = new Device ( readerSettings , "COM8" ) ;
163+ SerialDevice myDevice = new SerialDevice ( readerSettings , "COM8" ) ;
176164
177165 bool [ ] _probes = new bool [ 128 ] ;
178166
0 commit comments