/*
* Video On Demand Samples
*
* Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* You may also obtain this software under a propriety license from Microchip.
* Please contact Microchip for further information.
*
*/
/*----------------------------------------------------------*/
/*! \file
* \brief This file contains the CIndustrialStack class (API V3 commands).
*/
/*----------------------------------------------------------*/
#ifndef INDUSTRIAL_STACK_API_V3_H
#define INDUSTRIAL_STACK_API_V3_H
#include "IndustrialStack.h"
#include "Network.h"
#include "Types.h"
class CV3_OnMostRx : public CSInternalEvent
{
private:
CNetworkDevice *device;
public:
CV3_OnMostRx(CNetworkDevice *d) : device(d)
{
}
virtual ISReturn_t OnMostMessage(CIndustrialStack *iStack, CISMostMsg *r)
{
assert(NULL != device);
assert(r->IsValid);
if (0x0 == r->FBlock) //INIC Block
{
switch (r->Func)
{
case 0x520: //MOST Network Status
if (CISOpType_STATUS == r->OpType && r->PayloadLen == 11)
{
bool mpValChanged = ( 0 != ( r->Payload[1] & 0x1 ) ); //This is a 16 Bit value!!
bool systemNotOk = false; //Not transmitted any longer
bool mostAvailable = ( 0 != ( r->Payload[2] & 0x1 ) );
uint8_t availableSubState = r->Payload[3];
uint8_t availableTransition = r->Payload[4];
uint16_t nodeAddress = r->Payload[5] << 8
| r->Payload[6];
uint8_t nodePos = ( r->Payload[7] & 0x3F );
uint8_t maxPos = ( r->Payload[8] );
uint16_t packetBW = r->Payload[9] << 8
| r->Payload[10];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnNetworkState(device,
mpValChanged, systemNotOk, mostAvailable, availableSubState,
availableTransition, nodeAddress, nodePos, maxPos, packetBW);
}
break;
case 0x524: //MOST Network Startup
if (CISOpType_STATUS == r->OpType)
{
if (r->Payload[0] == 0x20 && r->Payload[1] == 0x04 && r->Payload[2] == 0x40)
return ISReturn_NoChange; //Startup was called, but we already have locked network, so ignore this error
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnNetworkStartupV3(device, (CISOpType_STATUS == r->OpType));
}
break;
case 0x527: //RBD Result
if (CISOpType_STATUS == r->OpType && r->PayloadLen == 5)
{
uint8_t result = r->Payload[0];
uint8_t position = r->Payload[1];
uint8_t status = r->Payload[2];
uint16_t id = r->Payload[3] << 8
| r->Payload[4];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnRbdResultV3(device, r->SourceAddress,
result, position, status, id);
}
break;
}
}
else if (0x1 == r->FBlock) //NetBlock FBlock
{
switch (r->Func)
{
case 0x004: //GroupAddress Changed
if (CISOpType_STATUS == r->OpType && r->PayloadLen >= 2)
{
uint16_t groupAddress = r->Payload[0] << 8
| r->Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnMostDeviceType(device, true, r->SourceAddress, groupAddress );
}
else if (CISOpType_ERROR == r->OpType)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnMostDeviceType(device, false, r->SourceAddress, 0xFFFF );
}
break;
case 0x013: //NetBlock EUI48
if (CISOpType_STATUS == r->OpType && r->PayloadLen >= 6)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnMostMacAddress(device, true,
r->SourceAddress, r->Payload[0], r->Payload[1],
r->Payload[2], r->Payload[3], r->Payload[4], r->Payload[5]);
}
else if (CISOpType_ERROR == r->OpType)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOf
# SPDX-License-Identifier: MIT
kconf hardware virtio.cfg