bool ProprietaryMessageA_c::sendWithPrio( unsigned prio, const IsoName_c& a_overwrite_remote ) {

    isoaglib_assert( prio <= 7 );
    isoaglib_assert(m_ident);
    // do not allow overwrite to a different target if m_remote is specified
    isoaglib_assert(!m_remote.isSpecified() || a_overwrite_remote.isUnspecified() || (a_overwrite_remote == m_remote));

    const uint32_t pgn = ( uint32_t( m_dp ) << 16) | PROPRIETARY_A_PGN;
    if (getDataSend().getLen() <= 8)
    {
      CanPkgExt_c pkg;

      pkg.setIsoPri( static_cast<uint8_t>( prio ) );
      pkg.setIsoPgn( pgn );
      pkg.setISONameForDA( a_overwrite_remote.isSpecified() ? a_overwrite_remote : m_remote );
      pkg.setMonitorItemForSA( m_ident->getIsoItem() );
      pkg.setDataFromString ( getDataSend().getDataStream(), static_cast<uint8_t>( getDataSend().getLen() ) );
      getIsoBusInstance( m_ident->getMultitonInst() ) << pkg;
      return true;
    }
    else
    { /** multi-packet */
      /** variable should be evaluated */
      // const bool cb_couldStartMultiSend =
      // we could catch the information if the sending succeeded, but what to do with it anyway?
      return getMultiSendInstance( m_ident->getMultitonInst() ).sendIsoTarget(
         m_ident->isoName(),
         a_overwrite_remote.isSpecified() ? a_overwrite_remote : m_remote,
         getDataSend().getDataStream(0),
         getDataSend().getLen(),
         pgn,
         this );
    }
  }
  bool ProprietaryMessageB_c::send( uint8_t ps ) {

    isoaglib_assert(m_ident);

    const uint32_t pgn = ( uint32_t( m_dp ) << 16) | PROPRIETARY_B_PGN | ps;
    if (getDataSend().getLen() <= 8)
    {
      CanPkgExt_c pkg;

      pkg.setIsoPri( 6 );
      pkg.setIsoPgn( pgn );
      pkg.setMonitorItemForSA( m_ident->getIsoItem() );
      pkg.setDataFromString ( getDataSend().getDataStream(), static_cast<uint8_t>( getDataSend().getLen() ) );
      getIsoBusInstance( m_ident->getMultitonInst() ) << pkg;
      return true;
    }
    else
    { /** multi-packet */
      /** variable should be evaluated */
      // const bool cb_couldStartMultiSend =
      // we could catch the information if the sending succeeded, but what to do with it anyway?
      return getMultiSendInstance( m_ident->getMultitonInst() ).sendIsoTarget(
         m_ident->isoName(),
         m_remote,
         getDataSend().getDataStream(0),
         getDataSend().getLen(),
         pgn,
         this );
    }
  }
Esempio n. 3
0
  TracLight_c::SendMessage_e TracLight_c::helpSendMessage( CanPkgExt_c& pkg )
  {
    // there is no need to check for address claim in tractor mode because this is already done in the timeEvent
    // function of base class BaseCommon_c

    pkg.setMonitorItemForSA( getIdentItem()->getIsoItem() );
    pkg.setLen(8);

    uint16_t ui16_temp = 0;
    ui16_temp =
      (mt_cmd.daytimeRunning <<  0) +
      (mt_cmd.alternateHead  <<  2) +
      (mt_cmd.lowBeamHead    <<  4) +
      (mt_cmd.highBeamHead   <<  6) +
      (mt_cmd.frontFog       <<  8) +
      (mt_cmd.beacon         << 10) +
      (mt_cmd.rightTurn      << 12) +
      (mt_cmd.leftTurn       << 14);
    pkg.setUint16Data(0, ui16_temp);
    ui16_temp = 0;
    ui16_temp =
      (mt_cmd.backUpLightAlarmHorn <<  0) +
      (mt_cmd.centerStop           <<  2) +
      (mt_cmd.rightStop            <<  4) +
      (mt_cmd.leftStop             <<  6) +
      (mt_cmd.implClearance        <<  8) +
      (mt_cmd.tracClearance        << 10) +
      (mt_cmd.implMarker           << 12) +
      (mt_cmd.tracMarker           << 14);
    pkg.setUint16Data(2, ui16_temp);
    ui16_temp = 0;
    ui16_temp =
      (mt_cmd.rearFog       <<  0) +
      (mt_cmd.undersideWork <<  2) +
      (mt_cmd.rearLowWork   <<  4) +
      (mt_cmd.rearHighWork  <<  6) +
      (mt_cmd.sideLowWork   <<  8) +
      (mt_cmd.sideHighWork  << 10) +
      (mt_cmd.frontLowWork  << 12) +
      (mt_cmd.frontHighWork << 14);
    pkg.setUint16Data(4, ui16_temp);

    // CanIo_c::operator<< retreives the information with the help of CanPkg_c::getData
    // then it sends the data
    getIsoBusInstance4Comm() << pkg;
    return MessageSent;
  }
Esempio n. 4
0
/** send a PGN request */
bool BaseCommon_c::sendPgnRequest(uint32_t ui32_requestedPGN)
{
  if( ( ! getIdentItem() ) || ( ! getIdentItem()->isClaimedAddress() ) )
    return false;

  IsoItem_c *dest = getSelectedDataSourceISONameConst().isSpecified()
    ? getIsoMonitorInstance( getIdentItem()->getMultitonInst() ).item( getSelectedDataSourceISONameConst(), true )
    : NULL; // --> ask to global

  CanPkgExt_c pkg;
  pkg.setIsoPri(6);
  pkg.setIsoPgn(REQUEST_PGN_MSG_PGN);
  pkg.setMonitorItemForSA( getIdentItem()->getIsoItem() );
  pkg.setMonitorItemForDA( dest );
  pkg.setLen( 3 );
  pkg.setUint32Data( 0 , ui32_requestedPGN );
  getIsoBusInstance( getIdentItem()->getMultitonInst() ) << pkg;
  return true;
}
Esempio n. 5
0
  /** send facilities data
      @see  TracFacilities_c::processMsgRequestPGN
      @see  CanIo_c::operator<<
    */
  void TracFacilities_c::sendFacilities( )
  {// there is no need to check for address claim because this is already done in the processMsgRequestPGN;
   // this function is only be called on request!!
    isoaglib_assert( getIdentItem() );

    IsoBus_c& c_can = getIsoBusInstance4Comm();

    CanPkgExt_c pkg;
    pkg.setMonitorItemForSA( getIdentItem()->getIsoItem() );
    setSelectedDataSourceISOName( getIdentItem()->isoName() );
    pkg.setIsoPri(3);
    pkg.setLen(8);

    pkg.setIsoPgn(TRACTOR_FACILITIES_PGN);

    for (uint8_t ui8_counter = 0;ui8_counter<sizeof(arrui8_facilitiesBitData)/sizeof(uint8_t);++ui8_counter)
      pkg.setUint8Data(ui8_counter,arrui8_facilitiesBitData[ui8_counter]);

    // CanIo_c::operator<< retreives the information with the help of CanPkg_c::getData
    // then it sends the data
    c_can << pkg;
  }