@@ -267,7 +267,7 @@ int32_t CruBar::getLinksPerWrapper(int wrapper)
267267// / calling this function, or the card may crash. See parseFirmwareFeatures().
268268boost::optional<int32_t > CruBar::getSerialNumber ()
269269{
270- assertBarIndex (2 , " Can only get serial number from BAR 2" );
270+ mPdaBar -> assertBarIndex (2 , " Can only get serial number from BAR 2" );
271271 uint32_t serial = readRegister (Cru::Registers::SERIAL_NUMBER.index );
272272 if (serial == 0x0 ) { // Try to populate the serial register in case it's empty
273273 writeRegister (Cru::Registers::SERIAL_NUMBER_CTRL.index , Cru::Registers::SERIAL_NUMBER_TRG);
@@ -280,16 +280,16 @@ boost::optional<int32_t> CruBar::getSerialNumber()
280280 boost::optional<int32_t > serial = eeprom.getSerial ();
281281 return serial;
282282 } else { // v3.6.3+
283+ // Register format e.g. 0x343230
284+ // translates to -> 024
285+ std::stringstream serialString;
283286
284- std::string serialString;
285-
286- for (int i = 0 ; i < 3 ; i++) { // The serial number consists of 3 digits
287- serialString += char (serial & 0xff );
288- serial = serial >> 8 ;
289- }
287+ serialString << char (serial & 0xff )
288+ << char ((serial & 0xff00 ) >> 8 )
289+ << char ((serial & 0xff0000 ) >> 16 );
290290
291291 try {
292- return std::stol (serialString, NULL , 0 );
292+ return std::stoi (serialString. str () );
293293 } catch (...) {
294294 return {};
295295 }
@@ -299,7 +299,7 @@ boost::optional<int32_t> CruBar::getSerialNumber()
299299// / Get raw data from the temperature register
300300uint32_t CruBar::getTemperatureRaw ()
301301{
302- assertBarIndex (2 , " Can only get temperature from BAR 2" );
302+ mPdaBar -> assertBarIndex (2 , " Can only get temperature from BAR 2" );
303303 // Only use lower 10 bits
304304 return readRegister (Cru::Registers::TEMPERATURE.index ) & 0x3ff ;
305305}
@@ -332,55 +332,55 @@ boost::optional<float> CruBar::getTemperatureCelsius()
332332
333333uint32_t CruBar::getFirmwareCompileInfo ()
334334{
335- assertBarIndex (0 , " Can only get firmware compile info from BAR 0" );
335+ mPdaBar -> assertBarIndex (0 , " Can only get firmware compile info from BAR 0" );
336336 return readRegister (Cru::Registers::FIRMWARE_COMPILE_INFO.index );
337337}
338338
339339uint32_t CruBar::getFirmwareGitHash ()
340340{
341- assertBarIndex (2 , " Can only get git hash from BAR 2" );
341+ mPdaBar -> assertBarIndex (2 , " Can only get git hash from BAR 2" );
342342 return readRegister (Cru::Registers::FIRMWARE_GIT_HASH.index );
343343}
344344
345345uint32_t CruBar::getFirmwareDateEpoch ()
346346{
347- assertBarIndex (2 , " Can only get firmware epoch from BAR 2" );
347+ mPdaBar -> assertBarIndex (2 , " Can only get firmware epoch from BAR 2" );
348348 return readRegister (Cru::Registers::FIRMWARE_EPOCH.index );
349349}
350350
351351uint32_t CruBar::getFirmwareDate ()
352352{
353- assertBarIndex (2 , " Can only get firmware date from BAR 2" );
353+ mPdaBar -> assertBarIndex (2 , " Can only get firmware date from BAR 2" );
354354 return readRegister (Cru::Registers::FIRMWARE_DATE.index );
355355}
356356
357357uint32_t CruBar::getFirmwareTime ()
358358{
359- assertBarIndex (2 , " Can only get firmware time from BAR 2" );
359+ mPdaBar -> assertBarIndex (2 , " Can only get firmware time from BAR 2" );
360360 return readRegister (Cru::Registers::FIRMWARE_TIME.index );
361361}
362362
363363uint32_t CruBar::getFpgaChipHigh ()
364364{
365- assertBarIndex (2 , " Can only get FPGA chip ID from BAR 2" );
365+ mPdaBar -> assertBarIndex (2 , " Can only get FPGA chip ID from BAR 2" );
366366 return readRegister (Cru::Registers::FPGA_CHIP_HIGH.index );
367367}
368368
369369uint32_t CruBar::getFpgaChipLow ()
370370{
371- assertBarIndex (2 , " Can only get FPGA chip ID from BAR 2" );
371+ mPdaBar -> assertBarIndex (2 , " Can only get FPGA chip ID from BAR 2" );
372372 return readRegister (Cru::Registers::FPGA_CHIP_LOW.index );
373373}
374374
375375uint32_t CruBar::getPonStatusRegister ()
376376{
377- assertBarIndex (2 , " Can only get PON status register from BAR 2" );
377+ mPdaBar -> assertBarIndex (2 , " Can only get PON status register from BAR 2" );
378378 return readRegister ((Cru::Registers::ONU_USER_LOGIC.address + 0x0c ) / 4 );
379379}
380380
381381uint32_t CruBar::getOnuAddress ()
382382{
383- assertBarIndex (2 , " Can only get PON status register from BAR 2" );
383+ mPdaBar -> assertBarIndex (2 , " Can only get PON status register from BAR 2" );
384384 return readRegister (Cru::Registers::ONU_USER_LOGIC.index ) >> 1 ;
385385}
386386
@@ -399,7 +399,7 @@ bool CruBar::checkPonUpstreamStatusExpected(uint32_t ponUpstreamRegister, uint32
399399// / Get the enabled features for the card's firmware.
400400FirmwareFeatures CruBar::parseFirmwareFeatures ()
401401{
402- assertBarIndex (0 , " Can only get firmware features from BAR 0" );
402+ mPdaBar -> assertBarIndex (0 , " Can only get firmware features from BAR 0" );
403403 return convertToFirmwareFeatures (readRegister (Cru::Registers::FIRMWARE_FEATURES.index ));
404404}
405405
0 commit comments