00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "LOW_linkDS2480B.h"
00020
00021
00022 LOW_linkDS2480B::LOW_linkDS2480B( const LOW_portSerialFactory::portSpecifier_t &inSerPortSpec, const RXPOL_val_t inRXPOL,
00023 const bool inHasExternalPower, const bool inAllowProgPulse) :
00024 LOW_link( true, inHasExternalPower, inAllowProgPulse),
00025 LOW_linkFlexibleSpeed( normal_speed, pdSlewRate_1_37, w1LowTime_11, soW0RecTime_10),
00026 receivePolarity( inRXPOL)
00027 {
00028 serialPort = LOW_portSerialFactory::new_portSerial( inSerPortSpec);
00029
00030 resetLinkAdapter();
00031 }
00032
00033
00034 LOW_linkDS2480B::~LOW_linkDS2480B()
00035 {
00036 serialPort->tty_flush();
00037
00038 delete serialPort;
00039 }
00040
00041
00042
00043
00044
00045
00046
00047 bool LOW_linkDS2480B::touchBit( const bool inSendBit, const strongPullup_t inPullup)
00048 {
00049 commLock lock( *this);
00050
00051 if ( inPullup != pullUp_NONE ) {
00052 setStrongPullupDuration_cmd( strongPullup_2_SPUD_val( inPullup));
00053 }
00054
00055 return singleBit_cmd( inSendBit, (inPullup==pullUp_NONE)?false:true);
00056 }
00057
00058
00059 uint8_t LOW_linkDS2480B::touchByte( const uint8_t inSendByte, const strongPullup_t inPullup)
00060 {
00061 commLock lock( *this);
00062
00063 if ( inPullup != pullUp_NONE ) {
00064 setStrongPullupDuration_cmd( strongPullup_2_SPUD_val( inPullup));
00065 pulse_cmd( true, false, true);
00066 }
00067
00068 setMode( data_mode);
00069
00070 serialPort->tty_write( inSendByte);
00071 if ( inSendByte == SwitchToCommandMode_Cmd )
00072 serialPort->tty_write( inSendByte);
00073
00074 uint8_t retValue = serialPort->tty_readByte( (inPullup==pullUp_NONE)?false:true);
00075
00076 if ( inPullup != pullUp_NONE ) {
00077 pulse_cmd( false, false, true);
00078 }
00079
00080 return retValue;
00081 }
00082
00083
00084 byteVec_t LOW_linkDS2480B::touchBlock( const byteVec_t &inBytes, const strongPullup_t inPullup)
00085 {
00086 if ( inBytes.size() == 0 ) return byteVec_t( 0);
00087
00088 commLock lock( *this);
00089
00090 byteVec_t retValue = byteVec_t( inBytes.size()-1);
00091 byteVec_t writeBytes;
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 for( unsigned int a=0; a<inBytes.size()-1; a++) {
00105 writeBytes.push_back( inBytes[a]);
00106 if ( inBytes[a] == SwitchToCommandMode_Cmd )
00107 writeBytes.push_back( inBytes[a]);
00108 }
00109
00110 setMode( data_mode);
00111
00112 if ( writeBytes.size() > 0 ) {
00113 serialPort->tty_write( writeBytes);
00114 serialPort->tty_read( retValue, false);
00115 }
00116
00117
00118 uint8_t lastByte = touchByte( inBytes[inBytes.size()-1], inPullup);
00119 retValue.push_back( lastByte);
00120
00121 return retValue;
00122 }
00123
00124
00125
00126
00127
00128
00129
00130
00131 void LOW_linkDS2480B::resetLinkAdapter()
00132 {
00133 commLock lock( *this);
00134
00135 internalMode = command_mode;
00136
00137
00138
00139
00140 serialPort->tty_configure( LOW_portSerial::none_flowControl, LOW_portSerial::bit8_size,
00141 LOW_portSerial::no_parity, LOW_portSerial::bit1_stopBit,
00142 LOW_portSerial::B9600_speed);
00143
00144 serialPort->tty_flush();
00145
00146 serialPort->tty_break();
00147 LOW_platformMisc::milliSleep( 2);
00148
00149 serialPort->tty_flush();
00150
00151
00152
00153
00154 serialPort->tty_write( SerialSpeedAdapt_Cmd);
00155 serialPort->tty_flush( false, true);
00156 LOW_platformMisc::milliSleep( 4);
00157
00158
00159
00160
00161 RBR_val_t serialSpeed;
00162 switch ( wireSpeed ) {
00163 case normal_speed: serialSpeed = RBR_9_6; break;
00164 case flexible_speed: serialSpeed = RBR_9_6; break;
00165 case overdrive_speed: serialSpeed = RBR_57_6; break;
00166 default: throw comm_error( "Unknown wire speed detected", __FILE__, __LINE__);
00167 }
00168 try {
00169 setRS232BaudRate_cmd( serialSpeed, receivePolarity);
00170 }
00171 catch ( ...) {}
00172
00173
00174
00175
00176 switch ( wireSpeed ) {
00177 case normal_speed:
00178 serialPort->tty_configure( LOW_portSerial::none_flowControl, LOW_portSerial::bit8_size,
00179 LOW_portSerial::no_parity, LOW_portSerial::bit1_stopBit,
00180 LOW_portSerial::B9600_speed);
00181 break;
00182
00183 case flexible_speed:
00184 serialPort->tty_configure( LOW_portSerial::none_flowControl, LOW_portSerial::bit8_size,
00185 LOW_portSerial::no_parity, LOW_portSerial::bit1_stopBit,
00186 LOW_portSerial::B9600_speed);
00187 break;
00188
00189 case overdrive_speed:
00190 serialPort->tty_configure( LOW_portSerial::none_flowControl, LOW_portSerial::bit8_size,
00191 LOW_portSerial::no_parity, LOW_portSerial::bit1_stopBit,
00192 LOW_portSerial::B57600_speed);
00193 break;
00194
00195 default:
00196 throw comm_error( "Unknown wire speed detected", __FILE__, __LINE__);
00197 }
00198
00199
00200 setRS232BaudRate_cmd( serialSpeed, receivePolarity);
00201
00202
00203
00204 if ( wireSpeed == flexible_speed ) {
00205 setPullDownSlewRate( pdSlewRate);
00206 setWrite1LowTime( w1LowTime);
00207 setSampleOffsetWrite0Rec( soW0RecTime);
00208 }
00209 }
00210
00211
00212 bool LOW_linkDS2480B::resetBus()
00213 {
00214 commLock lock( *this);
00215
00216 resetAnswer_t answer;
00217
00218 reset_cmd( &answer);
00219
00220 hasProgramPulse = answer.isVppPresent;
00221
00222
00223 switch( answer.busStatus ) {
00224 case oneWireShorted_busStat: throw comm_error( "Short to ground detected", __FILE__, __LINE__);
00225 case noPresencePulse_busStat: return false;
00226 case alarmingPresencePulse_busStat:
00227 case presencePulse_busStat:
00228 default: return true;
00229 }
00230 }
00231
00232
00233 void LOW_linkDS2480B::strongPullup( const unsigned long inMilliSecs)
00234 {
00235 commLock lock( *this);
00236
00237 switch ( inMilliSecs ) {
00238 case 16: strongPullup( pullUp_16_4); return;
00239 case 64: strongPullup( pullUp_65_5); return;
00240 case 128: strongPullup( pullUp_131); return;
00241 case 256: strongPullup( pullUp_262); return;
00242 case 512: strongPullup( pullUp_524); return;
00243 case 1024: strongPullup( pullUp_1048); return;
00244 default: break;
00245 }
00246
00247 pulse_cmd_manual( inMilliSecs, false);
00248 }
00249
00250
00251 void LOW_linkDS2480B::strongPullup( const strongPullup_t inPullupTimes)
00252 {
00253 commLock lock( *this);
00254
00255 unsigned int timeout = 0;
00256 switch( inPullupTimes ) {
00257 case pullUp_16_4:
00258 case pullUp_65_5:
00259 case pullUp_131:
00260 case pullUp_262:
00261 case pullUp_524: timeout = 1; break;
00262 case pullUp_1048: timeout = 2; break;
00263 default: throw internal_error( "Unknown strongPullup value detected", __FILE__, __LINE__);
00264 }
00265
00266 setStrongPullupDuration_cmd( strongPullup_2_SPUD_val( inPullupTimes));
00267 pulse_cmd( false, false, false, timeout);
00268 }
00269
00270
00271 void LOW_linkDS2480B::programPulse( const unsigned long inMicroSecs)
00272 {
00273 commLock lock( *this);
00274
00275 if ( ! allowProgPulse )
00276 throw notAllowed_error( "Program pulse not allowed", __FILE__, __LINE__);
00277
00278 if ( ! hasProgramPulse )
00279 throw illegalLevel_error( "Program pulse not available", __FILE__, __LINE__);
00280
00281 switch( inMicroSecs ) {
00282 case 32: programPulse( progPulse_32); return;
00283 case 64: programPulse( progPulse_64); return;
00284 case 128: programPulse( progPulse_128); return;
00285 case 256: programPulse( progPulse_256); return;
00286 case 512: programPulse( progPulse_512); return;
00287 case 1024: programPulse( progPulse_1024); return;
00288 case 2048: programPulse( progPulse_2048); return;
00289 default: break;
00290 }
00291
00292 pulse_cmd_manual( inMicroSecs, true);
00293 }
00294
00295
00296 void LOW_linkDS2480B::programPulse( const progPulse_t inPulseTime)
00297 {
00298 commLock lock( *this);
00299
00300 if ( ! allowProgPulse )
00301 throw notAllowed_error( "Program pulse not allowed", __FILE__, __LINE__);
00302
00303 if ( ! hasProgramPulse )
00304 throw illegalLevel_error( "Program pulse not available", __FILE__, __LINE__);
00305
00306 setProgPulseDuration_cmd( progPulse_2_PPD_val( inPulseTime));
00307 pulse_cmd( false, true, false);
00308 }
00309
00310
00311 void LOW_linkDS2480B::doSearchSequence( const LOW_deviceIDRaw &inBranchVector,
00312 LOW_deviceIDRaw &outFoundID, LOW_deviceIDRaw &outDiscrVec)
00313 {
00314 commLock lock( *this);
00315
00316 byteVec_t sendVector = byteVec_t( 16, 0x00);
00317
00318 int bitPos = 0;
00319 for( int a=0; a<16; a++) {
00320 for( int b=0; b<4; b++) {
00321 if ( inBranchVector.getBit( bitPos)==true )
00322 sendVector[a] |= 0x01<<(2*b+1);
00323
00324 bitPos++;
00325 }
00326 }
00327
00328 searchAccelCtrl_cmd( true);
00329 byteVec_t recVector = touchBlock( sendVector);
00330 searchAccelCtrl_cmd( false);
00331
00332 if ( recVector.size()!=16 )
00333 throw sizeMismatch_error( "Search received vector size mismatch", __FILE__, __LINE__);
00334
00335 bitPos = 0;
00336 for( int a=0; a<16; a++) {
00337 for( int b=0; b<4; b++) {
00338 if ( recVector[a] & (0x01<<((2*b)+1)) )
00339 outFoundID.setBit( bitPos, true);
00340 else
00341 outFoundID.setBit( bitPos, false);
00342
00343 if ( recVector[a] & (0x01<<(2*b)) )
00344 outDiscrVec.setBit( bitPos, true);
00345 else
00346 outDiscrVec.setBit( bitPos, false);
00347
00348 bitPos++;
00349 }
00350 }
00351
00352 }
00353
00354
00355
00356
00357
00358
00359
00360 void LOW_linkDS2480B::setWireSpeed( const wireSpeed_t inWireSpeed)
00361 {
00362 commLock lock( *this);
00363
00364 LOW_linkFlexibleSpeed::setWireSpeed( inWireSpeed);
00365
00366 resetLinkAdapter();
00367 resetBus();
00368 }
00369
00370
00371 LOW_linkDS2480B::wireSpeed_t LOW_linkDS2480B::getWireSpeed()
00372 {
00373 commLock lock( *this);
00374
00375 return wireSpeed;
00376 }
00377
00378
00379 void LOW_linkDS2480B::setPullDownSlewRate( const pdSlewRate_t inPDSR)
00380 {
00381 commLock lock( *this);
00382
00383 LOW_linkFlexibleSpeed::setPullDownSlewRate( inPDSR);
00384
00385 setPullDownSlewRate_cmd( pdSlewRate_2_PDSR_val( inPDSR));
00386 }
00387
00388
00389 LOW_linkDS2480B::pdSlewRate_t LOW_linkDS2480B::getPullDownSlewRate()
00390 {
00391 commLock lock( *this);
00392
00393 LOW_linkFlexibleSpeed::getPullDownSlewRate();
00394
00395 return PDSR_val_2_pdSlewRate( getPullDownSlewRate_cmd());
00396 }
00397
00398
00399 void LOW_linkDS2480B::setWrite1LowTime( const w1LowTime_t inW1LT)
00400 {
00401 commLock lock( *this);
00402
00403 LOW_linkFlexibleSpeed::setWrite1LowTime( inW1LT);
00404
00405 setWrite1LowTime_cmd( w1LowTime_2_W1LT_val(inW1LT));
00406 }
00407
00408
00409 LOW_linkDS2480B::w1LowTime_t LOW_linkDS2480B::getWrite1LowTime()
00410 {
00411 commLock lock( *this);
00412
00413 LOW_linkFlexibleSpeed::getWrite1LowTime();
00414
00415 return W1LT_val_2_w1LowTime( getWrite1LowTime_cmd());
00416 }
00417
00418
00419 void LOW_linkDS2480B::setSampleOffsetWrite0Rec( const soW0RecTime_t inSOW0RT)
00420 {
00421 commLock lock( *this);
00422
00423 LOW_linkFlexibleSpeed::setSampleOffsetWrite0Rec( inSOW0RT);
00424
00425 setSampleOffsetWrite0Rec_cmd( soW0RecTime_2_SOW0RT_val(inSOW0RT));
00426 }
00427
00428
00429 LOW_linkDS2480B::soW0RecTime_t LOW_linkDS2480B::getSampleOffsetWrite0Rec()
00430 {
00431 commLock lock( *this);
00432
00433 LOW_linkFlexibleSpeed::getSampleOffsetWrite0Rec();
00434
00435 return SOW0RT_val_2_soW0RecTime( getSampleOffsetWrite0Rec_cmd());
00436 }
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 void LOW_linkDS2480B::reset_cmd( resetAnswer_t *outAnswer)
00447 {
00448
00449
00450 setMode( command_mode);
00451
00452 serialPort->tty_flush();
00453
00454 uint8_t outByte = Reset_Cmd | (wireSpeed_2_OWSPEED_val( wireSpeed)&0x03)<<2;
00455 serialPort->tty_write( outByte);
00456
00457 uint8_t reply = serialPort->tty_readByte();
00458
00459 if ( (reply&0xc0) != (outByte&0xc0) )
00460 throw comm_error( "Unexpected reply from reset command", __FILE__, __LINE__);
00461
00462 outAnswer->busStatus = static_cast<busStatus_t>(reply&0x03);
00463 outAnswer->isVppPresent = (reply>>5)&0x01;
00464 outAnswer->chipRevision = (reply>>2)&0x07;
00465 }
00466
00467
00468 bool LOW_linkDS2480B::singleBit_cmd( const bool inBitVal, const bool inStrongPullup)
00469 {
00470
00471
00472 setMode( command_mode);
00473
00474 uint8_t outByte = SingleBit_Cmd | (static_cast<uint8_t>(inBitVal))<<4
00475 | (wireSpeed_2_OWSPEED_val( wireSpeed)&0x03)<<2
00476 | (static_cast<uint8_t>(inStrongPullup))<<1;
00477 serialPort->tty_write( outByte);
00478
00479 uint8_t reply = serialPort->tty_readByte();
00480
00481 if ( (reply&0xfc) != (outByte&0xfc) )
00482 throw comm_error( "Unexpected reply from single bit command", __FILE__, __LINE__);
00483
00484 bool retVal = reply&0x01;
00485
00486 if ( inStrongPullup ) {
00487 reply = serialPort->tty_readByte();
00488 if ( (reply&0xfc) != 0xec )
00489 throw comm_error( "Unexpected reply from single bit strong pullup response", __FILE__, __LINE__);
00490 }
00491
00492 return retVal;
00493 }
00494
00495
00496 void LOW_linkDS2480B::pulse_cmd( const bool inArm, const bool inProgPulse, const bool inImmidiateTerm, const unsigned int inSecTimeout)
00497 {
00498
00499
00500 setMode( command_mode);
00501
00502 byteVec_t outBytes;
00503
00504 outBytes.push_back( Pulse_Cmd | (static_cast<uint8_t>(inProgPulse))<<4
00505 | (0x03)<<2
00506 | (static_cast<uint8_t>(inArm))<<1);
00507 if ( inImmidiateTerm )
00508 outBytes.push_back( static_cast<uint8_t>( PulseTermination_Cmd));
00509
00510 serialPort->tty_write( outBytes);
00511
00512 uint8_t reply = serialPort->tty_readByte( false, inSecTimeout);
00513
00514 if ( (reply&0xfc) != (outBytes[0]&0xfc) )
00515 throw comm_error( "Unexpected reply from pulse command", __FILE__, __LINE__);
00516 }
00517
00518
00519 void LOW_linkDS2480B::pulse_cmd_manual( const unsigned long inSleepTime, const bool inProgPulse)
00520 {
00521
00522
00523 setMode( command_mode);
00524
00525 if ( inProgPulse )
00526 setProgPulseDuration_cmd( PPD_inf);
00527 else
00528 setStrongPullupDuration_cmd( SPUD_inf);
00529
00530 uint8_t outByte = Pulse_Cmd | (static_cast<uint8_t>(inProgPulse))<<4
00531 | (0x03)<<2;
00532
00533 serialPort->tty_write( outByte);
00534
00535 if ( inProgPulse )
00536 LOW_platformMisc::microSleep( inSleepTime);
00537 else
00538 LOW_platformMisc::milliSleep( inSleepTime);
00539
00540 serialPort->tty_write( static_cast<uint8_t>( PulseTermination_Cmd));
00541
00542 uint8_t reply = serialPort->tty_readByte( false);
00543
00544 if ( (reply&0xfc) != (outByte&0xfc) )
00545 throw comm_error( "Unexpected reply from pulse command", __FILE__, __LINE__);
00546 }
00547
00548
00549 void LOW_linkDS2480B::searchAccelCtrl_cmd( const bool inAccelOn)
00550 {
00551
00552
00553 setMode( command_mode);
00554
00555 uint8_t outByte = SearchAccel_Cmd | (static_cast<uint8_t>(inAccelOn))<<4
00556 | (wireSpeed_2_OWSPEED_val( wireSpeed)&0x03)<<2 ;
00557 serialPort->tty_write( outByte);
00558 }
00559
00560
00561
00562
00563
00564
00565
00566
00567 void LOW_linkDS2480B::setPullDownSlewRate_cmd( const PDSR_val_t inPDSR)
00568 {
00569
00570
00571 writeConfigValue( PullDownSlewRate_cfgCmd, inPDSR);
00572 }
00573
00574 LOW_linkDS2480B::PDSR_val_t LOW_linkDS2480B::getPullDownSlewRate_cmd()
00575 {
00576
00577
00578 return static_cast<PDSR_val_t>(readConfigValue( PullDownSlewRate_cfgCmd));
00579 }
00580
00581
00582 void LOW_linkDS2480B::setProgPulseDuration_cmd( const PPD_val_t inPPD)
00583 {
00584
00585
00586 writeConfigValue( ProgPulseDuration_cfgCmd, inPPD);
00587 }
00588
00589 LOW_linkDS2480B::PPD_val_t LOW_linkDS2480B::getProgPulseDuration_cmd()
00590 {
00591
00592
00593 return static_cast<PPD_val_t>(readConfigValue( ProgPulseDuration_cfgCmd));
00594 }
00595
00596
00597 void LOW_linkDS2480B::setStrongPullupDuration_cmd( const SPUD_val_t inSPUD)
00598 {
00599
00600
00601 writeConfigValue( StrongPullupDuration_cfgCmd, inSPUD);
00602 }
00603
00604 LOW_linkDS2480B::SPUD_val_t LOW_linkDS2480B::getStrongPullupDuration_cmd()
00605 {
00606
00607
00608 return static_cast<SPUD_val_t>(readConfigValue( StrongPullupDuration_cfgCmd));
00609 }
00610
00611
00612 void LOW_linkDS2480B::setWrite1LowTime_cmd( const W1LT_val_t inW1LT)
00613 {
00614
00615
00616 writeConfigValue( Write1LowTime_cfgCmd, inW1LT);
00617 }
00618
00619 LOW_linkDS2480B::W1LT_val_t LOW_linkDS2480B::getWrite1LowTime_cmd()
00620 {
00621
00622
00623 return static_cast<W1LT_val_t>(readConfigValue( Write1LowTime_cfgCmd));
00624 }
00625
00626
00627 void LOW_linkDS2480B::setSampleOffsetWrite0Rec_cmd( const SOW0RT_val_t inSOW0RT)
00628 {
00629
00630
00631 writeConfigValue( SampleOffsetWrite0Rec_cfgCmd, inSOW0RT);
00632 }
00633
00634 LOW_linkDS2480B::SOW0RT_val_t LOW_linkDS2480B::getSampleOffsetWrite0Rec_cmd()
00635 {
00636
00637
00638 return static_cast<SOW0RT_val_t>(readConfigValue( SampleOffsetWrite0Rec_cfgCmd));
00639 }
00640
00641
00642 void LOW_linkDS2480B::setLoadSensorThreshold_cmd( const LST_val_t inLST)
00643 {
00644
00645
00646 writeConfigValue( LoadSensorThreshold_cfgCmd, inLST);
00647 }
00648
00649 LOW_linkDS2480B::LST_val_t LOW_linkDS2480B::getLoadSensorThreshold_cmd()
00650 {
00651
00652
00653 return static_cast<LST_val_t>(readConfigValue( LoadSensorThreshold_cfgCmd));
00654 }
00655
00656
00657 void LOW_linkDS2480B::setRS232BaudRate_cmd( const RBR_val_t inRBR, const RXPOL_val_t inRXPOL)
00658 {
00659
00660
00661 writeConfigValue( RS232BaudRate_cfgCmd, ((inRXPOL&0x01)<<2) | (inRBR&0x03) );
00662 }
00663
00664 LOW_linkDS2480B::RBR_val_t LOW_linkDS2480B::getRS232BaudRate_cmd()
00665 {
00666
00667
00668 return static_cast<RBR_val_t>(readConfigValue( RS232BaudRate_cfgCmd) & 0x03);
00669 }
00670
00671 LOW_linkDS2480B::RXPOL_val_t LOW_linkDS2480B::getRS232RxPol_cmd()
00672 {
00673
00674
00675 return static_cast<RXPOL_val_t>((readConfigValue( RS232BaudRate_cfgCmd)>>2) & 0x01);
00676 }
00677
00678
00679
00680
00681
00682
00683
00684
00685 void LOW_linkDS2480B::writeConfigValue( const uint8_t inParamCode, const uint8_t inParamValue)
00686 {
00687
00688
00689 uint8_t outByte = (inParamCode&0x07)<<4 | (inParamValue&0x07)<<1 | 0x01;
00690 uint8_t expectedReply = outByte & ~0x01;
00691
00692 setMode( command_mode);
00693
00694 serialPort->tty_write( outByte);
00695 if ( serialPort->tty_readByte() != expectedReply )
00696 throw comm_error( "Unexpected reply while setting config value", __FILE__, __LINE__);
00697 }
00698
00699
00700 uint8_t LOW_linkDS2480B::readConfigValue( const uint8_t inParamCode)
00701 {
00702
00703
00704 uint8_t outByte = (inParamCode&0x07)<<1 | 0x01;
00705
00706 setMode( command_mode);
00707
00708 serialPort->tty_write( outByte);
00709
00710 uint8_t reply = serialPort->tty_readByte();
00711 if ( (reply&0x01)!=0x00 || (reply&0x70)!=0x00 )
00712 throw comm_error( "Unexpected reply while getting config value", __FILE__, __LINE__);
00713
00714 return (reply>>1)&0x07;
00715 }
00716
00717
00718 void LOW_linkDS2480B::setMode( const internalMode_t inMode)
00719 {
00720
00721
00722 if ( internalMode == inMode )
00723 return;
00724
00725 if ( internalMode==command_mode && inMode==data_mode ) {
00726 serialPort->tty_write( SwitchToDataMode_Cmd);
00727 internalMode = inMode;
00728 }
00729 else if ( internalMode==data_mode && inMode==command_mode ) {
00730 serialPort->tty_write( SwitchToCommandMode_Cmd);
00731 internalMode = inMode;
00732 }
00733 else {
00734 throw internal_error( "Illegal mode transition detected", __FILE__, __LINE__);
00735 }
00736 }
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746 const LOW_linkDS2480B::SPUD_val_t LOW_linkDS2480B::strongPullup_2_SPUD_val( const strongPullup_t inStrongPullup) const
00747 {
00748
00749
00750 switch( inStrongPullup ) {
00751 case pullUp_16_4: return SPUD_16_4;
00752 case pullUp_65_5: return SPUD_65_5;
00753 case pullUp_131: return SPUD_131;
00754 case pullUp_262: return SPUD_262;
00755 case pullUp_524: return SPUD_524;
00756 case pullUp_1048: return SPUD_1048;
00757 default: throw internal_error( "Unknown strongPullup_t value detected", __FILE__, __LINE__);
00758 }
00759 }
00760
00761
00762 const LOW_linkDS2480B::PPD_val_t LOW_linkDS2480B::progPulse_2_PPD_val( const progPulse_t inProgPulse) const
00763 {
00764
00765
00766 switch( inProgPulse ) {
00767 case progPulse_32: return PPD_32;
00768 case progPulse_64: return PPD_64;
00769 case progPulse_128: return PPD_128;
00770 case progPulse_256: return PPD_256;
00771 case progPulse_512: return PPD_512;
00772 case progPulse_1024: return PPD_1024;
00773 case progPulse_2048: return PPD_2048;
00774 default: throw internal_error( "Unknown progPulse_t value detected", __FILE__, __LINE__);
00775 }
00776 }
00777
00778
00779 const LOW_linkDS2480B::pdSlewRate_t LOW_linkDS2480B::PDSR_val_2_pdSlewRate( const PDSR_val_t inPDSR_val) const
00780 {
00781
00782
00783 switch( inPDSR_val ) {
00784 case PDSR_15: return pdSlewRate_15;
00785 case PDSR_2_2: return pdSlewRate_2_2;
00786 case PDSR_1_65: return pdSlewRate_1_65;
00787 case PDSR_1_37: return pdSlewRate_1_37;
00788 case PDSR_1_1: return pdSlewRate_1_1;
00789 case PDSR_0_83: return pdSlewRate_0_83;
00790 case PDSR_0_7: return pdSlewRate_0_7;
00791 case PDSR_0_55: return pdSlewRate_0_55;
00792 default: throw internal_error( "Unknown PDSR_val_t value detected", __FILE__, __LINE__);
00793 }
00794 }
00795
00796 const LOW_linkDS2480B::PDSR_val_t LOW_linkDS2480B::pdSlewRate_2_PDSR_val( const pdSlewRate_t inPdSlewRate_t) const
00797 {
00798
00799
00800 switch( inPdSlewRate_t ) {
00801 case pdSlewRate_15: return PDSR_15;
00802 case pdSlewRate_2_2: return PDSR_2_2;
00803 case pdSlewRate_1_65: return PDSR_1_65;
00804 case pdSlewRate_1_37: return PDSR_1_37;
00805 case pdSlewRate_1_1: return PDSR_1_1;
00806 case pdSlewRate_0_83: return PDSR_0_83;
00807 case pdSlewRate_0_7: return PDSR_0_7;
00808 case pdSlewRate_0_55: return PDSR_0_55;
00809 default: throw internal_error( "Unknown pdSlewRate_t value detected", __FILE__, __LINE__);
00810 }
00811 }
00812
00813
00814 const LOW_linkDS2480B::w1LowTime_t LOW_linkDS2480B::W1LT_val_2_w1LowTime( const W1LT_val_t inW1LT_val) const
00815 {
00816
00817
00818 switch( inW1LT_val ) {
00819 case W1LT_8: return w1LowTime_8;
00820 case W1LT_9: return w1LowTime_9;
00821 case W1LT_10: return w1LowTime_10;
00822 case W1LT_11: return w1LowTime_11;
00823 case W1LT_12: return w1LowTime_12;
00824 case W1LT_13: return w1LowTime_13;
00825 case W1LT_14: return w1LowTime_14;
00826 case W1LT_15: return w1LowTime_15;
00827 default: throw internal_error( "Unknown W1LT_val_t value detected", __FILE__, __LINE__);
00828 }
00829 }
00830
00831 const LOW_linkDS2480B::W1LT_val_t LOW_linkDS2480B::w1LowTime_2_W1LT_val( const w1LowTime_t inW1LowTime) const
00832 {
00833
00834
00835 switch( inW1LowTime ) {
00836 case w1LowTime_8: return W1LT_8;
00837 case w1LowTime_9: return W1LT_9;
00838 case w1LowTime_10: return W1LT_10;
00839 case w1LowTime_11: return W1LT_11;
00840 case w1LowTime_12: return W1LT_12;
00841 case w1LowTime_13: return W1LT_13;
00842 case w1LowTime_14: return W1LT_14;
00843 case w1LowTime_15: return W1LT_15;
00844 default: throw internal_error( "Unknown w1LowTime_t value detected", __FILE__, __LINE__);
00845 }
00846 }
00847
00848
00849 const LOW_linkDS2480B::soW0RecTime_t LOW_linkDS2480B::SOW0RT_val_2_soW0RecTime( const SOW0RT_val_t inSOW0RT_val) const
00850 {
00851
00852
00853 switch( inSOW0RT_val ) {
00854 case SOW0RT_3: return soW0RecTime_3;
00855 case SOW0RT_4: return soW0RecTime_4;
00856 case SOW0RT_5: return soW0RecTime_5;
00857 case SOW0RT_6: return soW0RecTime_6;
00858 case SOW0RT_7: return soW0RecTime_7;
00859 case SOW0RT_8: return soW0RecTime_8;
00860 case SOW0RT_9: return soW0RecTime_9;
00861 case SOW0RT_10: return soW0RecTime_10;
00862 default: throw internal_error( "Unknown SOW0RT_val_t value detected", __FILE__, __LINE__);
00863 }
00864 }
00865
00866 const LOW_linkDS2480B::SOW0RT_val_t LOW_linkDS2480B::soW0RecTime_2_SOW0RT_val( const soW0RecTime_t inSoW0RecTime) const
00867 {
00868
00869
00870 switch( inSoW0RecTime ) {
00871 case soW0RecTime_3: return SOW0RT_3;
00872 case soW0RecTime_4: return SOW0RT_4;
00873 case soW0RecTime_5: return SOW0RT_5;
00874 case soW0RecTime_6: return SOW0RT_6;
00875 case soW0RecTime_7: return SOW0RT_7;
00876 case soW0RecTime_8: return SOW0RT_8;
00877 case soW0RecTime_9: return SOW0RT_9;
00878 case soW0RecTime_10: return SOW0RT_10;
00879 default: throw internal_error( "Unknown soW0RecTime_t value detected", __FILE__, __LINE__);
00880 }
00881 }
00882
00883
00884 const LOW_linkDS2480B::wireSpeed_t LOW_linkDS2480B::OWSPEED_val_2_wireSpeed( const OWSPEED_val_t inOWSPEED_val) const
00885 {
00886
00887
00888 switch( inOWSPEED_val ) {
00889 case normal_OWSPEED: return normal_speed;
00890 case flexible_OWSPEED: return flexible_speed;
00891 case overdrive_OWSPEED: return overdrive_speed;
00892 default: throw internal_error( "Unknown OWSPEED_val_t value detected", __FILE__, __LINE__);
00893 }
00894 }
00895
00896 const LOW_linkDS2480B::OWSPEED_val_t LOW_linkDS2480B::wireSpeed_2_OWSPEED_val( const wireSpeed_t inWireSpeed) const
00897 {
00898
00899
00900 switch( inWireSpeed ) {
00901 case normal_speed: return normal_OWSPEED;
00902 case flexible_speed: return flexible_OWSPEED;
00903 case overdrive_speed: return overdrive_OWSPEED;
00904 default: throw internal_error( "Unknown wireSpeed_t value detected", __FILE__, __LINE__);
00905 }
00906 }
00907