1+ using System ;
2+ using System . Collections . Generic ;
13using System . Diagnostics ;
4+ using System . IO ;
25using System . IO . Ports ;
6+ using System . Linq ;
37using System . Text ;
48using Avalonia ;
59using Avalonia . Controls ;
@@ -34,7 +38,6 @@ public partial class MainWindow : Window
3438 } ;
3539
3640 private readonly SerialPort _uartSerial = new ( ) ;
37- private readonly NORData _norData = new ( ) ;
3841
3942 public MainWindow ( )
4043 {
@@ -182,16 +185,16 @@ private async void Button_OnClick(object? sender, RoutedEventArgs e)
182185
183186 #region Extract PS5 Version
184187
185- SetData ( norPath , Offsets . One , 12 , ref _norData . OffsetOne , out _ ) ;
186- SetData ( norPath , Offsets . Two , 12 , ref _norData . OffsetTwo , out _ ) ;
188+ SetData ( norPath , Offsets . One , 12 , out string ? offsetOne , out _ ) ;
189+ SetData ( norPath , Offsets . Two , 12 , out string ? offsetTwo , out _ ) ;
187190
188- if ( _norData . OffsetOne ? . Contains ( "22020101" ) ?? false )
191+ if ( offsetOne ? . Contains ( "22020101" ) ?? false )
189192 {
190193 PS5ModelOut . Content = "Disc Edition" ;
191194 }
192195 else
193196 {
194- if ( _norData . OffsetTwo ? . Contains ( "22030101" ) ?? false )
197+ if ( offsetTwo ? . Contains ( "22030101" ) ?? false )
195198 {
196199 PS5ModelOut . Content = "Digital Edition" ;
197200 }
@@ -205,19 +208,19 @@ private async void Button_OnClick(object? sender, RoutedEventArgs e)
205208
206209 #region Extract Motherboard Serial Number
207210
208- SetData ( norPath , Offsets . MoboSerial , 16 , ref _norData . MoboSerial , out string moboSerialText ) ;
211+ SetData ( norPath , Offsets . MoboSerial , 16 , out string ? moboSerial , out string moboSerialText ) ;
209212
210- MotherboardSerialOut . Content = _norData . MoboSerial != null
213+ MotherboardSerialOut . Content = moboSerial != null
211214 ? moboSerialText
212215 : "Unknown" ;
213216
214217 #endregion
215218
216219 #region Extract Board Serial Number
217220
218- SetData ( norPath , Offsets . Serial , 17 , ref _norData . Serial , out string serialText ) ;
221+ SetData ( norPath , Offsets . Serial , 17 , out string ? serial , out string serialText ) ;
219222
220- if ( _norData . Serial != null )
223+ if ( serial != null )
221224 {
222225 SerialNumberOut . Content = serialText ;
223226 SerialNumberIn . Text = serialText ;
@@ -232,14 +235,14 @@ private async void Button_OnClick(object? sender, RoutedEventArgs e)
232235
233236 #region Extract WiFi Mac Address
234237
235- SetData ( norPath , Offsets . WiFiMAC , 6 , ref _norData . WiFiMAC , out _ ) ;
236- if ( _norData . WiFiMAC != null )
237- _norData . WiFiMAC = string . Join ( "" , _norData . WiFiMAC . Select ( ( c , i ) => i % 2 == 0 ? $ "{ c } " : $ "{ c } -") ) [ ..^ 1 ] ;
238+ SetData ( norPath , Offsets . WiFiMAC , 6 , out string ? wiFiMAC , out _ ) ;
239+ if ( wiFiMAC != null )
240+ wiFiMAC = string . Join ( "" , wiFiMAC . Select ( ( c , i ) => i % 2 == 0 ? $ "{ c } " : $ "{ c } -") ) [ ..^ 1 ] ;
238241
239- if ( _norData . WiFiMAC != null )
242+ if ( wiFiMAC != null )
240243 {
241- WiFiMACAddressOut . Content = _norData . WiFiMAC ;
242- WiFiMACAddressIn . Text = _norData . WiFiMAC ;
244+ WiFiMACAddressOut . Content = wiFiMAC ;
245+ WiFiMACAddressIn . Text = wiFiMAC ;
243246 }
244247 else
245248 {
@@ -251,14 +254,14 @@ private async void Button_OnClick(object? sender, RoutedEventArgs e)
251254
252255 #region Extract LAN Mac Address
253256
254- SetData ( norPath , Offsets . LANMAC , 6 , ref _norData . LANMAC , out _ ) ;
255- if ( _norData . LANMAC != null )
256- _norData . LANMAC = string . Join ( "" , _norData . LANMAC . Select ( ( c , i ) => i % 2 == 0 ? $ "{ c } " : $ "{ c } -") ) [ ..^ 1 ] ;
257+ SetData ( norPath , Offsets . LANMAC , 6 , out string ? lanmac , out _ ) ;
258+ if ( lanmac != null )
259+ lanmac = string . Join ( "" , lanmac . Select ( ( c , i ) => i % 2 == 0 ? $ "{ c } " : $ "{ c } -") ) [ ..^ 1 ] ;
257260
258- if ( _norData . LANMAC != null )
261+ if ( lanmac != null )
259262 {
260- LANMACAddressOut . Content = _norData . LANMAC ;
261- LANMACAddressIn . Text = _norData . LANMAC ;
263+ LANMACAddressOut . Content = lanmac ;
264+ LANMACAddressIn . Text = lanmac ;
262265 }
263266 else
264267 {
@@ -270,19 +273,19 @@ private async void Button_OnClick(object? sender, RoutedEventArgs e)
270273
271274 #region Extract Board Variant
272275
273- SetData ( norPath , Offsets . Variant , 19 , ref _norData . Variant , out string variantText ) ;
274- if ( _norData . Variant != null )
275- _norData . Variant = _norData . Variant . Replace ( "FF" , null ) ;
276+ SetData ( norPath , Offsets . Variant , 19 , out string ? variant , out string variantText ) ;
277+ if ( variant != null )
278+ variant = variant . Replace ( "FF" , null ) ;
276279
277280 variantText += " - " + Regions . GetValueOrDefault ( variantText [ ^ 3 ..^ 1 ] , "Unknown Region" ) ;
278281
279- BoardVariantOut . Content = _norData . Variant != null ? variantText : "Unknown" ;
282+ BoardVariantOut . Content = variant != null ? variantText : "Unknown" ;
280283
281284 #endregion
282285
283286 return ;
284287
285- void SetData ( string path , long offset , int bytes , ref string ? dataValue , out string outputText )
288+ void SetData ( string path , long offset , int bytes , out string ? dataValue , out string outputText )
286289 {
287290 try
288291 {
0 commit comments