License changed to Apache 2.0 - part3
This commit is contained in:
parent
eab1f2d54f
commit
dadf5023df
3 changed files with 75 additions and 115 deletions
22
README.md
22
README.md
|
|
@ -224,14 +224,14 @@ For older history see http://sourceforge.net/p/canopennode/code_complete/
|
|||
|
||||
License
|
||||
-------
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
|
|
|||
|
|
@ -4,43 +4,23 @@
|
|||
* @file CO_TIME.c
|
||||
* @ingroup CO_TIME
|
||||
* @author Julien PEYREGNE
|
||||
* @copyright
|
||||
* @copyright 2019 - 2020 Janez Paternoster
|
||||
*
|
||||
* This file is part of CANopenNode, an opensource CANopen Stack.
|
||||
* Project home page is <https://github.com/CANopenNode/CANopenNode>.
|
||||
* For more information on CANopen see <http://www.can-cia.org/>.
|
||||
*
|
||||
* CANopenNode is free and open source 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.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* 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.
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Following clarification and special exception to the GNU General Public
|
||||
* License is included to the distribution terms of CANopenNode:
|
||||
*
|
||||
* Linking this library statically or dynamically with other modules is
|
||||
* making a combined work based on this library. Thus, the terms and
|
||||
* conditions of the GNU General Public License cover the whole combination.
|
||||
*
|
||||
* As a special exception, the copyright holders of this library give
|
||||
* you permission to link this library with independent modules to
|
||||
* produce an executable, regardless of the license terms of these
|
||||
* independent modules, and to copy and distribute the resulting
|
||||
* executable under terms of your choice, provided that you also meet,
|
||||
* for each linked independent module, the terms and conditions of the
|
||||
* license of that module. An independent module is a module which is
|
||||
* not derived from or based on this library. If you modify this
|
||||
* library, you may extend this exception to your version of the
|
||||
* library, but you are not obliged to do so. If you do not wish
|
||||
* to do so, delete this exception statement from your version.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "CANopen.h"
|
||||
|
|
@ -57,7 +37,7 @@ static void CO_TIME_receive(void *object, const CO_CANrxMsg_t *msg){
|
|||
|
||||
TIME = (CO_TIME_t*)object; /* this is the correct pointer type of the first argument */
|
||||
operState = *TIME->operatingState;
|
||||
|
||||
|
||||
if((operState == CO_NMT_OPERATIONAL) || (operState == CO_NMT_PRE_OPERATIONAL)){
|
||||
SET_CANrxNew(TIME->CANrxNew);
|
||||
// Process Time from msg buffer
|
||||
|
|
@ -67,26 +47,26 @@ static void CO_TIME_receive(void *object, const CO_CANrxMsg_t *msg){
|
|||
TIME->receiveError = (uint16_t)msg->DLC;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
CO_ReturnError_t CO_TIME_init(
|
||||
CO_TIME_t *TIME,
|
||||
CO_EM_t *em,
|
||||
CO_SDO_t *SDO,
|
||||
uint8_t *operatingState,
|
||||
uint32_t COB_ID_TIMEMessage,
|
||||
uint32_t TIMECyclePeriod,
|
||||
CO_CANmodule_t *CANdevRx,
|
||||
uint16_t CANdevRxIdx,
|
||||
CO_CANmodule_t *CANdevTx,
|
||||
uint16_t CANdevTxIdx)
|
||||
CO_TIME_t *TIME,
|
||||
CO_EM_t *em,
|
||||
CO_SDO_t *SDO,
|
||||
uint8_t *operatingState,
|
||||
uint32_t COB_ID_TIMEMessage,
|
||||
uint32_t TIMECyclePeriod,
|
||||
CO_CANmodule_t *CANdevRx,
|
||||
uint16_t CANdevRxIdx,
|
||||
CO_CANmodule_t *CANdevTx,
|
||||
uint16_t CANdevTxIdx)
|
||||
{
|
||||
/* verify arguments */
|
||||
if(TIME==NULL || em==NULL || SDO==NULL || operatingState==NULL ||
|
||||
CANdevRx==NULL || CANdevTx==NULL){
|
||||
return CO_ERROR_ILLEGAL_ARGUMENT;
|
||||
}
|
||||
|
||||
|
||||
/* Configure object variables */
|
||||
TIME->isConsumer = (COB_ID_TIMEMessage&0x80000000L) ? true : false;
|
||||
TIME->isProducer = (COB_ID_TIMEMessage&0x40000000L) ? true : false;
|
||||
|
|
@ -95,7 +75,7 @@ CO_ReturnError_t CO_TIME_init(
|
|||
TIME->periodTime = TIMECyclePeriod;
|
||||
TIME->periodTimeoutTime = TIMECyclePeriod / 2 * 3;
|
||||
/* overflow? */
|
||||
if(TIME->periodTimeoutTime < TIMECyclePeriod)
|
||||
if(TIME->periodTimeoutTime < TIMECyclePeriod)
|
||||
TIME->periodTimeoutTime = 0xFFFFFFFFL;
|
||||
|
||||
CLEAR_CANrxNew(TIME->CANrxNew);
|
||||
|
|
@ -105,7 +85,7 @@ CO_ReturnError_t CO_TIME_init(
|
|||
TIME->em = em;
|
||||
TIME->operatingState = operatingState;
|
||||
|
||||
|
||||
|
||||
/* configure TIME consumer message reception */
|
||||
TIME->CANdevRx = CANdevRx;
|
||||
TIME->CANdevRxIdx = CANdevRxIdx;
|
||||
|
|
@ -134,11 +114,11 @@ CO_ReturnError_t CO_TIME_init(
|
|||
|
||||
return CO_ERROR_NO;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
uint8_t CO_TIME_process(
|
||||
CO_TIME_t *TIME,
|
||||
uint32_t timeDifference_ms)
|
||||
CO_TIME_t *TIME,
|
||||
uint32_t timeDifference_ms)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
uint32_t timerNew;
|
||||
|
|
@ -146,7 +126,7 @@ uint8_t CO_TIME_process(
|
|||
if(*TIME->operatingState == CO_NMT_OPERATIONAL || *TIME->operatingState == CO_NMT_PRE_OPERATIONAL){
|
||||
/* update TIME timer, no overflow */
|
||||
timerNew = TIME->timer + timeDifference_ms;
|
||||
if(timerNew > TIME->timer)
|
||||
if(timerNew > TIME->timer)
|
||||
TIME->timer = timerNew;
|
||||
|
||||
/* was TIME just received */
|
||||
|
|
@ -155,7 +135,7 @@ uint8_t CO_TIME_process(
|
|||
ret = 1;
|
||||
TIME->CANrxNew = false;
|
||||
}
|
||||
|
||||
|
||||
/* TIME producer */
|
||||
if(TIME->isProducer && TIME->periodTime){
|
||||
if(TIME->timer >= TIME->periodTime){
|
||||
|
|
@ -167,7 +147,7 @@ uint8_t CO_TIME_process(
|
|||
}
|
||||
|
||||
/* Verify TIME timeout if node is consumer */
|
||||
if(TIME->isConsumer && TIME->periodTime && TIME->timer > TIME->periodTimeoutTime
|
||||
if(TIME->isConsumer && TIME->periodTime && TIME->timer > TIME->periodTimeoutTime
|
||||
&& *TIME->operatingState == CO_NMT_OPERATIONAL)
|
||||
CO_errorReport(TIME->em, CO_EM_TIME_TIMEOUT, CO_EMC_COMMUNICATION, TIME->timer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,43 +4,23 @@
|
|||
* @file CO_TIME.c
|
||||
* @ingroup CO_TIME
|
||||
* @author Julien PEYREGNE
|
||||
* @copyright
|
||||
* @copyright 2019 - 2020 Janez Paternoster
|
||||
*
|
||||
* This file is part of CANopenNode, an opensource CANopen Stack.
|
||||
* Project home page is <https://github.com/CANopenNode/CANopenNode>.
|
||||
* For more information on CANopen see <http://www.can-cia.org/>.
|
||||
*
|
||||
* CANopenNode is free and open source 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.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* 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.
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Following clarification and special exception to the GNU General Public
|
||||
* License is included to the distribution terms of CANopenNode:
|
||||
*
|
||||
* Linking this library statically or dynamically with other modules is
|
||||
* making a combined work based on this library. Thus, the terms and
|
||||
* conditions of the GNU General Public License cover the whole combination.
|
||||
*
|
||||
* As a special exception, the copyright holders of this library give
|
||||
* you permission to link this library with independent modules to
|
||||
* produce an executable, regardless of the license terms of these
|
||||
* independent modules, and to copy and distribute the resulting
|
||||
* executable under terms of your choice, provided that you also meet,
|
||||
* for each linked independent module, the terms and conditions of the
|
||||
* license of that module. An independent module is a module which is
|
||||
* not derived from or based on this library. If you modify this
|
||||
* library, you may extend this exception to your version of the
|
||||
* library, but you are not obliged to do so. If you do not wish
|
||||
* to do so, delete this exception statement from your version.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -62,35 +42,35 @@ extern "C" {
|
|||
* CANopen TIME object protocol.
|
||||
*
|
||||
* For CAN identifier see #CO_Default_CAN_ID_t
|
||||
*
|
||||
*
|
||||
* TIME message is used for time synchronization of the nodes on network. One node
|
||||
* should be TIME producer, others can be TIME consumers. This is configured with
|
||||
* should be TIME producer, others can be TIME consumers. This is configured with
|
||||
* COB_ID_TIME object 0x1012 :
|
||||
*
|
||||
* - bit 31 should be set for a consumer
|
||||
* - bit 30 should be set for a producer
|
||||
*
|
||||
*
|
||||
*
|
||||
* ###TIME CONSUMER
|
||||
*
|
||||
*
|
||||
* CO_TIME_init() configuration :
|
||||
* - COB_ID_TIME : 0x80000100L -> TIME consumer with TIME_COB_ID = 0x100
|
||||
* - TIMECyclePeriod :
|
||||
* - TIMECyclePeriod :
|
||||
* - 0 -> no EMCY will be transmitted in case of TIME timeout
|
||||
* - X -> an EMCY will be transmitted in case of TIME timeout (X * 1.5) ms
|
||||
*
|
||||
* Latest time value is stored in \p CO->TIME->Time variable.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* ###TIME PRODUCER
|
||||
*
|
||||
*
|
||||
* CO_TIME_init() configuration :
|
||||
* - COB_ID_TIME : 0x40000100L -> TIME producer with TIME_COB_ID = 0x100
|
||||
* - TIMECyclePeriod : Time transmit period in ms
|
||||
*
|
||||
* Write time value in \p CO->TIME->Time variable, this will be sent at TIMECyclePeriod.
|
||||
*/
|
||||
|
||||
|
||||
#define TIME_MSG_LENGTH 6U
|
||||
|
||||
/**
|
||||
|
|
@ -106,7 +86,7 @@ typedef struct{
|
|||
variable from Object dictionary (index 0x1012). */
|
||||
bool_t isProducer;
|
||||
uint16_t COB_ID; /**< From CO_TIME_init() */
|
||||
/** TIME period time in [milliseconds]. Set to TIME period to enable
|
||||
/** TIME period time in [milliseconds]. Set to TIME period to enable
|
||||
timeout detection */
|
||||
uint32_t periodTime;
|
||||
/** TIME period timeout time in [milliseconds].
|
||||
|
|
@ -144,17 +124,17 @@ typedef struct{
|
|||
* @return #CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT.
|
||||
*/
|
||||
CO_ReturnError_t CO_TIME_init(
|
||||
CO_TIME_t *TIME,
|
||||
CO_EM_t *em,
|
||||
CO_SDO_t *SDO,
|
||||
uint8_t *operatingState,
|
||||
uint32_t COB_ID_TIMEMessage,
|
||||
uint32_t TIMECyclePeriod,
|
||||
CO_CANmodule_t *CANdevRx,
|
||||
uint16_t CANdevRxIdx,
|
||||
CO_CANmodule_t *CANdevTx,
|
||||
uint16_t CANdevTxIdx);
|
||||
|
||||
CO_TIME_t *TIME,
|
||||
CO_EM_t *em,
|
||||
CO_SDO_t *SDO,
|
||||
uint8_t *operatingState,
|
||||
uint32_t COB_ID_TIMEMessage,
|
||||
uint32_t TIMECyclePeriod,
|
||||
CO_CANmodule_t *CANdevRx,
|
||||
uint16_t CANdevRxIdx,
|
||||
CO_CANmodule_t *CANdevTx,
|
||||
uint16_t CANdevTxIdx);
|
||||
|
||||
/**
|
||||
* Process TIME communication.
|
||||
*
|
||||
|
|
@ -167,8 +147,8 @@ CO_ReturnError_t CO_TIME_init(
|
|||
* @return 1: New TIME message recently received (consumer) / transmited (producer).
|
||||
*/
|
||||
uint8_t CO_TIME_process(
|
||||
CO_TIME_t *TIME,
|
||||
uint32_t timeDifference_ms);
|
||||
CO_TIME_t *TIME,
|
||||
uint32_t timeDifference_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue