Primary LSS support, thanks to Jorge Berzosa.
--- a/configure Fri Dec 14 16:32:38 2007 +0100
+++ b/configure Mon Dec 17 13:22:35 2007 +0100
@@ -107,6 +107,8 @@
echo "On user request: Won't optimize with \"-Ox\"";;
--disable-dll) DISABLE_DLL=1;
echo "On user request: Won't create and link to dll";;
+ --enable-lss) ENABLE_LSS=1;
+ echo "On user request: LSS services enabled";;
--debug=*) DEBUG=$optarg;;
--MAX_CAN_BUS_ID=*) MAX_CAN_BUS_ID=$1;;
--SDO_MAX_LENGTH_TRANSFERT=*) SDO_MAX_LENGTH_TRANSFERT=$1;;
@@ -141,6 +143,7 @@
echo " see http://www.ocera.org/download/components/WP7/lincan-0.3.3.html"
echo " --timers=foo Use 'foo' as TIMERS driver (can be either 'unix' or 'xeno')"
echo " --disable-dll Disable run-time dynamic linking of can, led and nvram drivers"
+ echo " --enable-lss Enable the LSS services"
echo " --disable-Ox Disable gcc \"-Ox\" optimizations."
echo " --debug=foo,foo,.. Enable debug messages, ERR -> only errors, WAR)."
echo " \"PDO\" send errors and warnings through PDO messages"
@@ -567,6 +570,13 @@
SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ $SUB_CAN_DLL_CFLAGS
fi
+if [ $ENABLE_LSS ]; then
+ SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DCO_ENABLE_LSS;
+ SUB_ENABLE_LSS=1
+else
+ SUB_ENABLE_LSS=0
+fi
+
###########################################################################
# CREATE MAKEFILES #
###########################################################################
@@ -636,6 +646,7 @@
s:SUB_CAN_DRIVER:can_${SUB_CAN_DRIVER}:
s:SUB_CAN_DLL_CFLAGS:${SUB_CAN_DLL_CFLAGS}:
s:SUB_ENABLE_DLL_DRIVERS:${SUB_ENABLE_DLL_DRIVERS}:
+ s:SUB_ENABLE_LSS:${SUB_ENABLE_LSS}:
" > $makefile
done
--- a/examples/TestMasterSlave/Master.c Fri Dec 14 16:32:38 2007 +0100
+++ b/examples/TestMasterSlave/Master.c Mon Dec 17 13:22:35 2007 +0100
@@ -143,12 +143,181 @@
}
}
+#ifdef CO_ENABLE_LSS
+static void ConfigureLSSNode(CO_Data* d);
+UNS8 init_step_LSS=1;
+
+static void CheckLSSAndContinue(CO_Data* d, UNS8 command)
+{
+ UNS32 dat1;
+ UNS8 dat2;
+ printf("CheckLSS->");
+ if(getConfigResultNetworkNode (d, command, &dat1, &dat2) != LSS_FINISHED){
+ if(command==LSS_IDENT_NON_CONF_SLAVE){
+ eprintf("Master : There are not no-configured slaves in the net\n", command);
+ return;
+ }
+ else{
+ eprintf("Master : Failed in LSS comand %d. Trying again\n", command);
+ }
+ }
+ else
+ {
+ init_step_LSS++;
+
+ switch(command){
+ case LSS_CONF_NODE_ID:
+ switch(dat1){
+ case 0: printf("Node ID change succesful\n");break;
+ case 1: printf("Node ID change error:out of range\n");break;
+ case 0xFF:printf("Node ID change error:specific error\n");break;
+ default:break;
+ }
+ break;
+ case LSS_CONF_BIT_TIMING:
+ switch(dat1){
+ case 0: printf("Baud rate change succesful\n");break;
+ case 1: printf("Baud rate change error: change baud rate not supported\n");break;
+ case 0xFF:printf("Baud rate change error:specific error\n");break;
+ default:break;
+ }
+ break;
+ case LSS_CONF_STORE:
+ switch(dat1){
+ case 0: printf("Store configuration succesful\n");break;
+ case 1: printf("Store configuration error:not supported\n");break;
+ case 0xFF:printf("Store configuration error:specific error\n");break;
+ default:break;
+ }
+ break;
+ case LSS_SM_SELECTIVE_RESP:
+ printf("Slave in CONFIGURATION mode\n");
+ break;
+ case LSS_IDENT_SLAVE:
+ printf("node identified\n");
+ break;
+ case LSS_IDENT_NON_CONF_SLAVE:
+ printf("non-configured remote slave in the net\n");
+ break;
+ case LSS_INQ_VENDOR_ID:
+ printf("Slave VendorID %x\n", dat1);
+ break;
+ case LSS_INQ_PRODUCT_CODE:
+ printf("Slave Product Code %x\n", dat1);
+ break;
+ case LSS_INQ_REV_NUMBER:
+ printf("Slave Revision Number %x\n", dat1);
+ break;
+ case LSS_INQ_SERIAL_NUMBER:
+ printf("Slave Serial Number %x\n", dat1);
+ break;
+ case LSS_INQ_NODE_ID:
+ printf("Slave nodeid %x\n", dat1);
+ break;
+ }
+ }
+
+ printf("\n");
+ ConfigureLSSNode(d);
+}
+
+
+struct timeval master_prev_time,master_current_time;
+static void ConfigureLSSNode(CO_Data* d)
+{
+ UNS32 Vendor_ID=0x12345678;
+ UNS32 Product_Code=0x90123456;
+ UNS32 Revision_Number=0x78901234;
+ UNS32 Serial_Number=0x56789012;
+ UNS32 Revision_Number_high=0x78901240;
+ UNS32 Revision_Number_low=0x78901230;
+ UNS32 Serial_Number_high=0x56789020;
+ UNS32 Serial_Number_low=0x56789010;
+ UNS8 NodeID=0x02;
+ UNS8 Baud_Table=0;
+ UNS8 Baud_BitTiming=3;
+ UNS16 Switch_delay=1;
+ UNS8 LSS_mode=LSS_WAITING_MODE;
+ UNS8 res;
+ eprintf("ConfigureLSSNode-> ");
+
+ switch(init_step_LSS){
+ case 1: /* LSS=>identify non-configured remote slave */
+ eprintf("LSS=>identify non-configured remote slave\n");
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_IDENT_REMOTE_NON_CONF,0,0,CheckLSSAndContinue);
+ break;
+ case 2: /* LSS=>identify node */
+ eprintf("LSS=>identify node\n");
+ res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_VENDOR,&Vendor_ID,0);
+ res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_PRODUCT,&Product_Code,0);
+ res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_REV_LOW,&Revision_Number_low,0);
+ res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_REV_HIGH,&Revision_Number_high,0);
+ res=configNetworkNode(&TestMaster_Data,LSS_IDENT_REMOTE_SERIAL_LOW,&Serial_Number_low,0);
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_IDENT_REMOTE_SERIAL_HIGH,&Serial_Number_high,0,CheckLSSAndContinue);
+ break;
+ case 3: /*First step : setup Slave's TPDO 1 to be transmitted on SYNC*/
+ eprintf("LSS=>put in configuration mode\n");
+ res=configNetworkNode(&TestMaster_Data,LSS_SM_SELECTIVE_VENDOR,&Vendor_ID,0);
+ res=configNetworkNode(&TestMaster_Data,LSS_SM_SELECTIVE_PRODUCT,&Product_Code,0);
+ res=configNetworkNode(&TestMaster_Data,LSS_SM_SELECTIVE_REVISION,&Revision_Number,0);
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_SM_SELECTIVE_SERIAL,&Serial_Number,0,CheckLSSAndContinue);
+ break;
+ case 4: /* LSS=>inquire nodeID */
+ eprintf("LSS=>inquire nodeID\n");
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_INQ_NODE_ID,0,0,CheckLSSAndContinue);
+ break;
+ case 5: /* LSS=>inquire VendorID */
+ eprintf("LSS=>inquire VendorID\n");
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_INQ_VENDOR_ID,0,0,CheckLSSAndContinue);
+ break;
+ case 6: /* LSS=>inquire Product code */
+ eprintf("LSS=>inquire Product code\n");
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_INQ_PRODUCT_CODE,0,0,CheckLSSAndContinue);
+ break;
+ case 7: /* LSS=>inquire Revision Number */
+ eprintf("LSS=>inquire Revision Number\n");
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_INQ_REV_NUMBER,0,0,CheckLSSAndContinue);
+ break;
+ case 8: /* LSS=>inquire Serial Number */
+ eprintf("LSS=>inquire Serial Number\n");
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_INQ_SERIAL_NUMBER,0,0,CheckLSSAndContinue);
+ break;
+ case 9: /* LSS=>change the nodeID */
+ eprintf("LSS=>change the nodeId\n");
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_CONF_NODE_ID,&NodeID,0,CheckLSSAndContinue);
+ break;
+ case 10: /* LSS=>change the Baud rate */
+ eprintf("LSS=>change the Baud rate\n");
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_CONF_BIT_TIMING,&Baud_Table,&Baud_BitTiming,CheckLSSAndContinue);
+ break;
+ case 11:
+ eprintf("LSS=>Activate Bit Timing\n");
+ res=configNetworkNode(&TestMaster_Data,LSS_CONF_ACT_BIT_TIMING,&Switch_delay,0);
+ /*no break;*/
+ init_step_LSS++;
+ case 12:
+ /*LSS=>store configuration*/
+ /* It will fail the first time (time out) due to the switch delay */
+ /* It will fail the second time because it is not implemented in the slave */
+ eprintf("LSS=>store configuration\n");
+ res=configNetworkNodeCallBack(&TestMaster_Data,LSS_CONF_STORE,0,0,CheckLSSAndContinue);
+ break;
+ case 13: /* LSS=>put in operation mod */
+ eprintf("LSS=>put in operation mode\n");
+ res=configNetworkNode(&TestMaster_Data,LSS_SM_GLOBAL,&LSS_mode,0);
+ break;
+ }
+}
+#endif
+
void TestMaster_preOperational()
{
-
eprintf("TestMaster_preOperational\n");
- ConfigureSlaveNode(&TestMaster_Data, 0x02);
-
+#ifdef CO_ENABLE_LSS
+ /* Ask slave node to go in stop mode */
+ masterSendNMTstateChange (&TestMaster_Data, 0, NMT_Stop_Node);
+ ConfigureLSSNode(&TestMaster_Data);
+#endif
}
void TestMaster_operational()
@@ -286,3 +455,10 @@
}
MasterSyncCount++;
}
+
+void TestMaster_post_SlaveBootup(UNS8 nodeid)
+{
+ eprintf("TestMaster_post_SlaveBootup %x\n", nodeid);
+ ConfigureSlaveNode(&TestMaster_Data, nodeid);
+}
+
--- a/examples/TestMasterSlave/Master.h Fri Dec 14 16:32:38 2007 +0100
+++ b/examples/TestMasterSlave/Master.h Mon Dec 17 13:22:35 2007 +0100
@@ -12,3 +12,4 @@
void TestMaster_post_sync(void);
void TestMaster_post_TPDO(void);
void TestMaster_post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg);
+void TestMaster_post_SlaveBootup(UNS8 nodeid);
--- a/examples/TestMasterSlave/Slave.c Fri Dec 14 16:32:38 2007 +0100
+++ b/examples/TestMasterSlave/Slave.c Mon Dec 17 13:22:35 2007 +0100
@@ -24,6 +24,7 @@
#include "Master.h"
#include "TestMasterSlave.h"
+extern s_BOARD SlaveBoard;
/*****************************************************************************/
void TestSlave_heartbeatError(UNS8 heartbeatID)
{
@@ -113,3 +114,15 @@
{
eprintf("Slave received EMCY message. Node: %2.2x ErrorCode: %4.4x ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
}
+
+void TestSlave_StoreConfiguration(UNS8 *error, UNS8 *spec_error)
+{
+ printf("TestSlave_StoreConfiguration\n");
+}
+
+void TestSlave_ChangeBaudRate(char *baudrate)
+{
+ eprintf("TestSlave_ChangeBaudRate from %s to %s\n", SlaveBoard.baudrate, baudrate);
+ SlaveBoard.baudrate=baudrate;
+ /* something to do with the new baudrate */
+}
--- a/examples/TestMasterSlave/Slave.h Fri Dec 14 16:32:38 2007 +0100
+++ b/examples/TestMasterSlave/Slave.h Mon Dec 17 13:22:35 2007 +0100
@@ -13,3 +13,5 @@
void TestSlave_post_TPDO(void);
void TestSlave_storeODSubIndex(UNS16 wIndex, UNS8 bSubindex);
void TestSlave_post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg);
+void TestSlave_StoreConfiguration(UNS8 *error, UNS8 *spec_error);
+void TestSlave_ChangeBaudRate(char *baudrate);
--- a/examples/TestMasterSlave/TestMasterSlave.c Fri Dec 14 16:32:38 2007 +0100
+++ b/examples/TestMasterSlave/TestMasterSlave.c Mon Dec 17 13:22:35 2007 +0100
@@ -94,8 +94,14 @@
{
/****************************** INITIALISATION SLAVE *******************************/
if(strcmp(SlaveBoard.baudrate, "none")) {
- /* Defining the node Id */
+
+#ifdef CO_ENABLE_LSS
+ /* Set an invalid nodeID */
+ setNodeId(&TestSlave_Data, 0xFF);
+#else
setNodeId(&TestSlave_Data, 0x02);
+#endif
+
/* init */
setState(&TestSlave_Data, Initialisation);
}
@@ -121,7 +127,7 @@
int c;
extern char *optarg;
- char* LibraryPath="libcanfestival_can_virtual.so";
+ char* LibraryPath="../../drivers/can_virtual/libcanfestival_can_virtual.so";
while ((c = getopt(argc, argv, "-m:s:M:S:l:")) != EOF)
{
@@ -196,6 +202,11 @@
TestSlave_Data.post_TPDO = TestSlave_post_TPDO;
TestSlave_Data.storeODSubIndex = TestSlave_storeODSubIndex;
TestSlave_Data.post_emcy = TestSlave_post_emcy;
+#ifdef CO_ENABLE_LSS
+ /* in this example the slave doesn't support Store configuration*/
+ //TestSlave_Data.lss_StoreConfiguration = TestSlave_StoreConfiguration;
+ TestSlave_Data.lss_ChangeBaudRate=TestSlave_ChangeBaudRate;
+#endif
if(!canOpen(&SlaveBoard,&TestSlave_Data)){
eprintf("Cannot open Slave Board (%s,%s)\n",SlaveBoard.busname, SlaveBoard.baudrate);
@@ -212,6 +223,7 @@
TestMaster_Data.post_sync = TestMaster_post_sync;
TestMaster_Data.post_TPDO = TestMaster_post_TPDO;
TestMaster_Data.post_emcy = TestMaster_post_emcy;
+ TestMaster_Data.post_SlaveBootup=TestMaster_post_SlaveBootup;
if(!canOpen(&MasterBoard,&TestMaster_Data)){
eprintf("Cannot open Master Board (%s,%s)\n",MasterBoard.busname, MasterBoard.baudrate);
--- a/examples/TestMasterSlave/TestSlave.c Fri Dec 14 16:32:38 2007 +0100
+++ b/examples/TestMasterSlave/TestSlave.c Mon Dec 17 13:22:35 2007 +0100
@@ -200,10 +200,10 @@
/* index 0x1018 : Identity. */
UNS8 TestSlave_highestSubIndex_obj1018 = 4; /* number of subindex - 1*/
- UNS32 TestSlave_obj1018_Vendor_ID = 0x0; /* 0 */
- UNS32 TestSlave_obj1018_Product_Code = 0x0; /* 0 */
- UNS32 TestSlave_obj1018_Revision_Number = 0x0; /* 0 */
- UNS32 TestSlave_obj1018_Serial_Number = 0x0; /* 0 */
+ UNS32 TestSlave_obj1018_Vendor_ID = 0x12345678; /* 305419896 */
+ UNS32 TestSlave_obj1018_Product_Code = 0x90123456; /* 2417112150 */
+ UNS32 TestSlave_obj1018_Revision_Number = 0x78901234; /* 2022707764 */
+ UNS32 TestSlave_obj1018_Serial_Number = 0x56789012; /* 1450741778 */
subindex TestSlave_Index1018[] =
{
{ RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1018 },
--- a/examples/TestMasterSlave/TestSlave.od Fri Dec 14 16:32:38 2007 +0100
+++ b/examples/TestMasterSlave/TestSlave.od Mon Dec 17 13:22:35 2007 +0100
@@ -1,10 +1,10 @@
<?xml version="1.0"?>
<!DOCTYPE PyObject SYSTEM "PyObjects.dtd">
-<PyObject module="node" class="Node" id="11102832">
-<attr name="Profile" type="dict" id="18192832" >
+<PyObject module="node" class="Node" id="173730860">
+<attr name="Profile" type="dict" id="173740892" >
</attr>
<attr name="Name" type="string">TestSlave</attr>
-<attr name="Dictionary" type="dict" id="16242864" >
+<attr name="Dictionary" type="dict" id="172080772" >
<entry>
<key type="numeric" value="4096" />
<val type="numeric" value="301" />
@@ -59,7 +59,7 @@
</entry>
<entry>
<key type="numeric" value="6146" />
- <val type="list" id="11102184" >
+ <val type="list" id="171817420" >
<item type="string" value="{True:"$NODEID+0x%X80"%(base+1),False:0}[base<4]" />
<item type="numeric" value="255" />
<item type="numeric" value="5000" />
@@ -69,7 +69,7 @@
</entry>
<entry>
<key type="numeric" value="4112" />
- <val type="list" id="11101896" >
+ <val type="list" id="171817260" >
<item type="numeric" value="0" />
<item type="numeric" value="0" />
<item type="numeric" value="0" />
@@ -78,7 +78,7 @@
</entry>
<entry>
<key type="numeric" value="4113" />
- <val type="list" id="11102544" >
+ <val type="list" id="171776140" >
<item type="numeric" value="0" />
<item type="numeric" value="0" />
<item type="numeric" value="0" />
@@ -87,13 +87,13 @@
</entry>
<entry>
<key type="numeric" value="6658" />
- <val type="list" id="11102760" >
+ <val type="list" id="171817132" >
<item type="numeric" value="537591824" />
</val>
</entry>
<entry>
<key type="numeric" value="6147" />
- <val type="list" id="11102040" >
+ <val type="list" id="173731116" >
<item type="string" value="{True:"$NODEID+0x%X80"%(base+1),False:0}[base<4]" />
<item type="numeric" value="252" />
<item type="numeric" value="0" />
@@ -107,7 +107,7 @@
</entry>
<entry>
<key type="numeric" value="4608" />
- <val type="list" id="11102688" >
+ <val type="list" id="173731372" >
<item type="string" value=""$NODEID+0x600"" />
<item type="string" value=""$NODEID+0x580"" />
</val>
@@ -118,16 +118,16 @@
</entry>
<entry>
<key type="numeric" value="4120" />
- <val type="list" id="11110808" >
- <item type="numeric" value="0" />
- <item type="numeric" value="0" />
- <item type="numeric" value="0" />
- <item type="numeric" value="0" />
+ <val type="list" id="173731244" >
+ <item type="numeric" value="305419896" />
+ <item type="numeric" value="2417112150L" />
+ <item type="numeric" value="2022707764" />
+ <item type="numeric" value="1450741778" />
</val>
</entry>
<entry>
<key type="numeric" value="6148" />
- <val type="list" id="11103192" >
+ <val type="list" id="173731308" >
<item type="numeric" value="1025" />
<item type="numeric" value="253" />
<item type="numeric" value="0" />
@@ -149,7 +149,7 @@
</entry>
<entry>
<key type="numeric" value="6659" />
- <val type="list" id="11103264" >
+ <val type="list" id="173731628" >
<item type="numeric" value="537657360" />
</val>
</entry>
@@ -159,7 +159,7 @@
</entry>
<entry>
<key type="numeric" value="6144" />
- <val type="list" id="11103408" >
+ <val type="list" id="173731788" >
<item type="string" value="{True:"$NODEID+0x%X80"%(base+1),False:0}[base<4]" />
<item type="numeric" value="0" />
<item type="numeric" value="0" />
@@ -169,13 +169,13 @@
</entry>
<entry>
<key type="numeric" value="6660" />
- <val type="list" id="11111240" >
+ <val type="list" id="173731020" >
<item type="numeric" value="537657360" />
</val>
</entry>
<entry>
<key type="numeric" value="6656" />
- <val type="list" id="11102112" >
+ <val type="list" id="173744204" >
<item type="numeric" value="536870913" />
<item type="numeric" value="536936449" />
<item type="numeric" value="537001985" />
@@ -190,7 +190,7 @@
</entry>
<entry>
<key type="numeric" value="4099" />
- <val type="list" id="11110520" >
+ <val type="list" id="173744268" >
<item type="numeric" value="0" />
<item type="numeric" value="0" />
<item type="numeric" value="0" />
@@ -203,7 +203,7 @@
</entry>
<entry>
<key type="numeric" value="6145" />
- <val type="list" id="11111168" >
+ <val type="list" id="173744236" >
<item type="string" value="{True:"$NODEID+0x%X80"%(base+1),False:0}[base<4]" />
<item type="numeric" value="0" />
<item type="numeric" value="0" />
@@ -213,17 +213,17 @@
</entry>
<entry>
<key type="numeric" value="6657" />
- <val type="list" id="12077032" >
+ <val type="list" id="173744332" >
<item type="numeric" value="537526288" />
</val>
</entry>
</attr>
-<attr name="SpecificMenu" type="list" id="11101464" >
+<attr name="SpecificMenu" type="list" id="171777260" >
</attr>
-<attr name="ParamsDictionary" type="dict" id="16301408" >
+<attr name="ParamsDictionary" type="dict" id="173741436" >
<entry>
<key type="numeric" value="8192" />
- <val type="dict" id="15731648" >
+ <val type="dict" id="173742116" >
<entry>
<key type="string" value="callback" />
<val type="False" value="" />
@@ -232,10 +232,10 @@
</entry>
<entry>
<key type="numeric" value="6144" />
- <val type="dict" id="9567888" >
+ <val type="dict" id="173741164" >
<entry>
<key type="numeric" value="2" />
- <val type="dict" id="16301984" >
+ <val type="dict" id="172080092" >
<entry>
<key type="string" value="save" />
<val type="True" value="" />
@@ -244,7 +244,7 @@
</entry>
<entry>
<key type="numeric" value="3" />
- <val type="dict" id="19216992" >
+ <val type="dict" id="173742524" >
<entry>
<key type="string" value="save" />
<val type="True" value="" />
@@ -255,10 +255,10 @@
</entry>
<entry>
<key type="numeric" value="6146" />
- <val type="dict" id="16269424" >
+ <val type="dict" id="173741708" >
<entry>
<key type="numeric" value="2" />
- <val type="dict" id="19215136" >
+ <val type="dict" id="173742796" >
<entry>
<key type="string" value="comment" />
<val type="string">EVENT</val>
@@ -267,7 +267,7 @@
</entry>
<entry>
<key type="numeric" value="3" />
- <val type="dict" id="19215424" >
+ <val type="dict" id="173741572" >
<entry>
<key type="string" value="comment" />
<val type="string">5000*100 µC = 500 ms</val>
@@ -276,7 +276,7 @@
</entry>
<entry>
<key type="numeric" value="4" />
- <val type="dict" id="16249568" >
+ <val type="dict" id="173743068" >
<entry>
<key type="string" value="comment" />
<val type="string" value="" />
@@ -285,7 +285,7 @@
</entry>
<entry>
<key type="numeric" value="5" />
- <val type="dict" id="9568176" >
+ <val type="dict" id="173743204" >
<entry>
<key type="string" value="comment" />
<val type="string">1000 ms</val>
@@ -296,10 +296,10 @@
</entry>
<entry>
<key type="numeric" value="6147" />
- <val type="dict" id="16302272" >
+ <val type="dict" id="173741980" >
<entry>
<key type="numeric" value="2" />
- <val type="dict" id="19261968" >
+ <val type="dict" id="173742252" >
<entry>
<key type="string" value="comment" />
<val type="string">RTR_SYNC</val>
@@ -310,10 +310,10 @@
</entry>
<entry>
<key type="numeric" value="6148" />
- <val type="dict" id="19263360" >
+ <val type="dict" id="173742932" >
<entry>
<key type="numeric" value="2" />
- <val type="dict" id="19260976" >
+ <val type="dict" id="173743748" >
<entry>
<key type="string" value="comment" />
<val type="string">RTR</val>
@@ -324,7 +324,7 @@
</entry>
<entry>
<key type="numeric" value="4112" />
- <val type="dict" id="19261552" >
+ <val type="dict" id="173743612" >
<entry>
<key type="string" value="callback" />
<val type="True" value="" />
@@ -333,7 +333,7 @@
</entry>
<entry>
<key type="numeric" value="4113" />
- <val type="dict" id="16301120" >
+ <val type="dict" id="173743476" >
<entry>
<key type="string" value="callback" />
<val type="True" value="" />
@@ -342,7 +342,7 @@
</entry>
<entry>
<key type="numeric" value="4099" />
- <val type="dict" id="16249856" >
+ <val type="dict" id="173743884" >
<entry>
<key type="string" value="callback" />
<val type="True" value="" />
@@ -351,7 +351,7 @@
</entry>
<entry>
<key type="numeric" value="4119" />
- <val type="dict" id="19263648" >
+ <val type="dict" id="173742660" >
<entry>
<key type="string" value="callback" />
<val type="True" value="" />
@@ -359,18 +359,18 @@
</val>
</entry>
</attr>
-<attr name="UserMapping" type="dict" id="16251168" >
+<attr name="UserMapping" type="dict" id="173748404" >
<entry>
<key type="numeric" value="8192" />
- <val type="dict" id="19263936" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12076672" >
- <item type="dict" id="19257456" >
+ <val type="dict" id="173748812" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173731468" >
+ <item type="dict" id="173748948" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -402,15 +402,15 @@
</entry>
<entry>
<key type="numeric" value="8193" />
- <val type="dict" id="19264864" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="11111096" >
- <item type="dict" id="19390480" >
+ <val type="dict" id="173749084" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744364" >
+ <item type="dict" id="173748268" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -442,15 +442,15 @@
</entry>
<entry>
<key type="numeric" value="8194" />
- <val type="dict" id="19264576" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12077896" >
- <item type="dict" id="19215712" >
+ <val type="dict" id="173748540" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744396" >
+ <item type="dict" id="173749492" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -482,15 +482,15 @@
</entry>
<entry>
<key type="numeric" value="8195" />
- <val type="dict" id="19261264" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12077680" >
- <item type="dict" id="19265152" >
+ <val type="dict" id="173749628" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744460" >
+ <item type="dict" id="173749764" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -522,15 +522,15 @@
</entry>
<entry>
<key type="numeric" value="8196" />
- <val type="dict" id="19391360" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="11110952" >
- <item type="dict" id="19391072" >
+ <val type="dict" id="173748676" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744556" >
+ <item type="dict" id="173750036" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -562,15 +562,15 @@
</entry>
<entry>
<key type="numeric" value="8197" />
- <val type="dict" id="19388320" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12078256" >
- <item type="dict" id="19391840" >
+ <val type="dict" id="173743340" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744652" >
+ <item type="dict" id="173750308" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -602,15 +602,15 @@
</entry>
<entry>
<key type="numeric" value="8198" />
- <val type="dict" id="19389952" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12077608" >
- <item type="dict" id="19389664" >
+ <val type="dict" id="173749356" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744780" >
+ <item type="dict" id="173750580" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -642,15 +642,15 @@
</entry>
<entry>
<key type="numeric" value="8199" />
- <val type="dict" id="19394080" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12078400" >
- <item type="dict" id="19392368" >
+ <val type="dict" id="173749220" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744748" >
+ <item type="dict" id="173750852" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -682,15 +682,15 @@
</entry>
<entry>
<key type="numeric" value="8200" />
- <val type="dict" id="19394848" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12078184" >
- <item type="dict" id="19394560" >
+ <val type="dict" id="173749900" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744812" >
+ <item type="dict" id="173751124" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -722,15 +722,15 @@
</entry>
<entry>
<key type="numeric" value="8201" />
- <val type="dict" id="19395424" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12077968" >
- <item type="dict" id="19396432" >
+ <val type="dict" id="173750172" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744908" >
+ <item type="dict" id="173751396" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -762,15 +762,15 @@
</entry>
<entry>
<key type="numeric" value="8202" />
- <val type="dict" id="19396000" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12077752" >
- <item type="dict" id="19395712" >
+ <val type="dict" id="173750444" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173744876" >
+ <item type="dict" id="173751668" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -802,15 +802,15 @@
</entry>
<entry>
<key type="numeric" value="8203" />
- <val type="dict" id="19398736" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12078472" >
- <item type="dict" id="19397024" >
+ <val type="dict" id="173750716" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173745004" >
+ <item type="dict" id="173751940" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -842,15 +842,15 @@
</entry>
<entry>
<key type="numeric" value="8204" />
- <val type="dict" id="19399504" >
- <entry>
- <key type="string" value="need" />
- <val type="False" value="" />
- </entry>
- <entry>
- <key type="string" value="values" />
- <val type="list" id="12078544" >
- <item type="dict" id="19399216" >
+ <val type="dict" id="173750988" >
+ <entry>
+ <key type="string" value="need" />
+ <val type="False" value="" />
+ </entry>
+ <entry>
+ <key type="string" value="values" />
+ <val type="list" id="173745036" >
+ <item type="dict" id="173752364" >
<entry>
<key type="string" value="access" />
<val type="string" value="rw" />
@@ -881,7 +881,7 @@
</val>
</entry>
</attr>
-<attr name="DS302" type="dict" id="19400080" >
+<attr name="DS302" type="dict" id="173751260" >
</attr>
<attr name="ProfileName" type="string" value="DS-301" />
<attr name="Type" type="string">slave</attr>
--- a/include/data.h Fri Dec 14 16:32:38 2007 +0100
+++ b/include/data.h Mon Dec 17 13:22:35 2007 +0100
@@ -44,6 +44,9 @@
#include "sync.h"
#include "nmtMaster.h"
#include "emcy.h"
+#ifdef CO_ENABLE_LSS
+#include "lss.h"
+#endif
/* This structurs contains all necessary information for a CanOpen node */
struct struct_CO_Data {
@@ -85,6 +88,7 @@
/*UNS32 *Sync_window_length;;*/
post_sync_t post_sync;
post_TPDO_t post_TPDO;
+ post_SlaveBootup_t post_SlaveBootup;
/* General */
UNS8 toggle;
@@ -107,6 +111,12 @@
s_errors error_data[EMCY_MAX_ERRORS];
post_emcy_t post_emcy;
+#ifdef CO_ENABLE_LSS
+ /* LSS */
+ lss_transfer_t lss_transfer;
+ lss_StoreConfiguration_t lss_StoreConfiguration;
+ lss_ChangeBaudRate_t lss_ChangeBaudRate;
+#endif
};
#define NMTable_Initializer Unknown_state,
@@ -133,6 +143,36 @@
0, /* errRegMask */\
0 /* active */\
},
+
+#ifdef CO_ENABLE_LSS
+#define lss_Initializer {\
+ LSS_RESET, /* state */\
+ 0, /* command */\
+ LSS_WAITING_MODE, /* mode */\
+ 0, /* dat1 */\
+ 0, /* dat2 */\
+ Unknown_state, /* currentState */\
+ 0, /* NodeID */\
+ 0, /* addr_sel_match */\
+ 0, /* addr_ident_match */\
+ "none", /* BaudRate */\
+ 0, /* SwitchDelay */\
+ SDELAY_OFF, /* SwitchDelayState */\
+ {-1,-1}, /* Timers[2] */\
+ NULL, /* Callback */\
+ 0, /* IDNumber */\
+ 128, /* BitChecked */\
+ 0, /* LSSSub */\
+ 0, /* LSSNext */\
+ 0, /* LSSPos */\
+ LSS_FS_RESET /* FastScan_SM */\
+ },\
+ NULL, /* _lss_StoreConfiguration*/\
+ NULL /* _lss_ChangeBaudRate */
+#else
+#define lss_Initializer
+#endif
+
/* A macro to initialize the data in client app.*/
/* CO_Data structure */
@@ -186,6 +226,7 @@
/*& NODE_PREFIX ## _obj1007, */ /* Sync_window_length */\
_post_sync, /* post_sync */\
_post_TPDO, /* post_TPDO */\
+ _post_SlaveBootup, /* post_SlaveBootup */\
\
/* General */\
0, /* toggle */\
@@ -208,7 +249,9 @@
{\
REPEAT_EMCY_MAX_ERRORS_TIMES(ERROR_DATA_INITIALIZER)\
},\
- _post_emcy /* post_emcy */\
+ _post_emcy, /* post_emcy */\
+ /* LSS */\
+ lss_Initializer\
}
#ifdef __cplusplus
--- a/include/def.h Fri Dec 14 16:32:38 2007 +0100
+++ b/include/def.h Mon Dec 17 13:22:35 2007 +0100
@@ -114,6 +114,7 @@
#define SDOtx 0xB
#define SDOrx 0xC
#define NODE_GUARD 0xE
+#define LSS 0xF
/* NMT Command Specifier, sent by master to change a slave state */
/* ------------------------------------------------------------- */
@@ -124,6 +125,13 @@
#define NMT_Reset_Node 0x81
#define NMT_Reset_Comunication 0x82
+/** Status of the LSS transmission
+ */
+#define LSS_RESET 0x0 /* Transmission not started. Init state. */
+#define LSS_FINISHED 0x1 /* data are available */
+#define LSS_ABORTED_INTERNAL 0x2 /* Aborted but not because of an abort message. */
+#define LSS_TRANS_IN_PROGRESS 0x3
+
/* constantes used in the different state machines */
/* ----------------------------------------------- */
/* Must not be modified */
--- a/include/lifegrd.h Fri Dec 14 16:32:38 2007 +0100
+++ b/include/lifegrd.h Mon Dec 17 13:22:35 2007 +0100
@@ -29,6 +29,9 @@
typedef void (*heartbeatError_t)(UNS8);
void _heartbeatError(UNS8 heartbeatID);
+typedef void (*post_SlaveBootup_t)(UNS8);
+void _post_SlaveBootup(UNS8 SlaveID);
+
#include "data.h"
/*************************************************************************
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/lss.h Mon Dec 17 13:22:35 2007 +0100
@@ -0,0 +1,197 @@
+/*
+This file is part of CanFestival, a library implementing CanOpen Stack.
+
+Copyright (C): Jorge Berzosa
+
+See COPYING file for copyrights details.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __LSS_h__
+#define __LSS_h__
+
+#define SLSS_ADRESS 0x7E4
+#define MLSS_ADRESS 0x7E5
+
+#define LSS_MSG_TIMER 0
+#define LSS_SWITCH_DELAY_TIMER 1
+
+#define SDELAY_OFF 0
+#define SDELAY_FIRST 1
+#define SDELAY_SECOND 2
+
+#define LSS_WAITING_MODE 0
+#define LSS_CONFIGURATION_MODE 1
+
+/* Switch mode services */
+#define LSS_SM_GLOBAL 4
+#define LSS_SM_SELECTIVE_VENDOR 64
+#define LSS_SM_SELECTIVE_PRODUCT 65
+#define LSS_SM_SELECTIVE_REVISION 66
+#define LSS_SM_SELECTIVE_SERIAL 67
+#define LSS_SM_SELECTIVE_RESP 68
+/* Configuration services */
+#define LSS_CONF_NODE_ID 17
+#define LSS_CONF_BIT_TIMING 19
+#define LSS_CONF_ACT_BIT_TIMING 21
+#define LSS_CONF_STORE 23
+/* Inquire services */
+#define LSS_INQ_VENDOR_ID 90
+#define LSS_INQ_PRODUCT_CODE 91
+#define LSS_INQ_REV_NUMBER 92
+#define LSS_INQ_SERIAL_NUMBER 93
+#define LSS_INQ_NODE_ID 94
+/* Identification services */
+#define LSS_IDENT_REMOTE_VENDOR 70
+#define LSS_IDENT_REMOTE_PRODUCT 71
+#define LSS_IDENT_REMOTE_REV_LOW 72
+#define LSS_IDENT_REMOTE_REV_HIGH 73
+#define LSS_IDENT_REMOTE_SERIAL_LOW 74
+#define LSS_IDENT_REMOTE_SERIAL_HIGH 75
+#define LSS_IDENT_REMOTE_NON_CONF 76
+#define LSS_IDENT_SLAVE 79
+#define LSS_IDENT_NON_CONF_SLAVE 80
+#define LSS_IDENT_FASTSCAN 81
+
+/*FastScan State Machine*/
+#define LSS_FS_RESET 0
+
+
+typedef void (*LSSCallback_t)(CO_Data* d, UNS8 command);
+
+typedef void (*lss_StoreConfiguration_t)(UNS8*,UNS8*);
+//void _lss_StoreConfiguration(UNS8 *error, UNS8 *spec_error);
+
+typedef void (*lss_ChangeBaudRate_t)(char*);
+//void _lss_ChangeBaudRate(char *BaudRate);
+
+
+struct struct_lss_transfer;
+
+//#include "timer.h"
+
+/* The Transfer structure
+* Used to store the different fields of the internal state of the LSS
+*/
+
+struct struct_lss_transfer {
+ UNS8 state; /* state of the transmission : Takes the values LSS_... */
+ UNS8 command; /* the LSS command of the transmision */
+ UNS8 mode; /* LSS mode */
+
+ UNS32 dat1; /* the data from the last msg received */
+ UNS8 dat2;
+
+ e_nodeState currentState; /* the state of the node before switching to LSSTimingDelay*/
+ UNS8 nodeID; /* the new nodeid stored to update the nodeid when switching to LSS operational*/
+ UNS8 addr_sel_match; /* the matching mask for the LSS Switch Mode Selective service */
+ UNS8 addr_ident_match; /* the matching mask for the LSS Identify Remote Slaves service*/
+
+ char *baudRate; /* the new baudrate stored to update the node baudrate when a Activate Bit
+ * Timing Parameters is received*/
+ UNS16 switchDelay; /* the period of the two delay */
+ UNS8 switchDelayState; /* the state machine for the switchDelay */
+
+ TIMER_HANDLE timers[2]; /* Time counters to implement a timeout in milliseconds.
+ * LSS_MSG_TIMER (index 0) is automatically incremented whenever
+ * the lss state is in LSS_TRANS_IN_PROGRESS, and reseted to 0
+ * when the response LSS have been received.
+ * LSS_SWITCH_DELAY_TIMER (index 1) is automatically incremented whenever
+ * the lss switchDelayState is in SDELAY_FIRST or SDELAY_SECOND, and reseted to 0
+ * when the two periods have been expired.
+ */
+ LSSCallback_t Callback; /* The user callback func to be called at LSS transaction end */
+
+ UNS32 IDNumber;
+ UNS8 BitChecked;
+ UNS8 LSSSub;
+ UNS8 LSSNext;
+ UNS8 LSSPos;
+ UNS8 FastScan_SM;
+};
+
+#ifdef CO_ENABLE_LSS
+typedef struct struct_lss_transfer lss_transfer_t;
+#else
+typedef UNS8 lss_transfer_t;
+#endif
+
+
+void startLSS(CO_Data* d);
+void stopLSS(CO_Data* d);
+
+
+/** transmit a LSS message
+ * Checks if the msg can be transmited (i.e. we are not in LssTimingDelay state)
+ * command is the LSS command specifier
+ * dat1 and dat2 are pointers to optional data (depend on command)
+ * return sendLSSMessage(d,command,dat1,dat2)
+ */
+UNS8 sendLSS (CO_Data* d, UNS8 command,void *dat1, void *dat2);
+
+/** transmit a LSS message on CAN bus
+ * comamnd is the LSS command specifier
+ * bus_id is MLSS_ADRESS or SLSS_ADRESS depending in d->iam_a_slave.
+ * dat1 and dat2 are pointers to optional data (depend on command).
+ * return canSend(bus_id,&m)
+ */
+
+UNS8 sendLSSMessage(CO_Data* d, UNS8 command, void *dat1, void *dat2);
+
+/** This function is called when the node is receiving a Master LSS message (cob-id = 0x7E5).
+ * - Check if there is a callback which will take care of the response. If not return 0 but does nothing.
+ * - Stops the timer so the alarm wont raise an error.
+ * - return 0 if OK
+ */
+UNS8 proceedLSS_Master (CO_Data* d, Message* m );
+
+/** This function is called when the node is receiving a Slave LSS message (cob-id = 0x7E4).
+ * - Call the callback function or send the response message depending on the LSS comand within m.
+ * - return 0 if OK
+ */
+UNS8 proceedLSS_Slave (CO_Data* d, Message* m );
+
+/** Used by the Master application to send a LSS command, WITHOUT response, to the slave.
+ * command: the LSS command. LSS_...
+ * dat1 and dat2: pointers to optional data (depend on command).
+ * return sendLSS(d,command,dat1,dat2)
+ */
+UNS8 configNetworkNode(CO_Data* d, UNS8 command, void *dat1, void* dat2);
+
+/** Used by the Master application to send a LSS command, WITH response, to the slave.
+ * The function Callback, which must be defined in the user code, is called at the
+ * end of the exchange (on succes or abort) and can be NULL.
+ * The LSS_MSG_TIMER timer is started to control the timeout
+ * return sendLSS(d,command,dat1,dat2)
+ */
+UNS8 configNetworkNodeCallBack (CO_Data* d, UNS8 command, void *dat1, void* dat2, LSSCallback_t Callback);
+
+/** Use this function after a configNetworkNode or configNetworkNodeCallBack to get the result.
+ Returns : LSS_RESET // Transmission not started. Init state.
+ LSS_FINISHED // data are available
+ LSS_ABORTED_INTERNAL // Aborted but not because of an abort message.
+ LSS_TRANS_IN_PROGRESS // Data not yet available
+
+ * command: the LSS command (unused).
+ * example:
+ * UNS32 dat1;
+ * UNS8 dat2;
+ res=configNetworkNodeCallBack(&_Data,LSS_INQ_NODE_ID,0,0,NULL); // inquire the nodeID
+ while (getConfigResultNetworkNode (&_Data, LSS_INQ_NODE_ID, &dat1, &dat2) != LSS_TRANS_IN_PROGRESS);
+*/
+UNS8 getConfigResultNetworkNode (CO_Data* d, UNS8 command, UNS32* dat1, UNS8* dat2);
+
+#endif
--- a/include/states.h Fri Dec 14 16:32:38 2007 +0100
+++ b/include/states.h Mon Dec 17 13:22:35 2007 +0100
@@ -40,7 +40,10 @@
Stopped = 0x04,
Operational = 0x05,
Pre_operational = 0x7F,
- Unknown_state = 0x0F
+ Unknown_state = 0x0F,
+#ifdef CO_ENABLE_LSS
+ LssTimingDelay = 0x10
+#endif
};
typedef enum enum_nodeState e_nodeState;
@@ -53,6 +56,7 @@
INTEGER8 csSYNC;
INTEGER8 csHeartbeat;
INTEGER8 csPDO;
+ INTEGER8 csLSS;
} s_state_communication;
/** Function that user app can overload
--- a/src/Makefile.in Fri Dec 14 16:32:38 2007 +0100
+++ b/src/Makefile.in Mon Dec 17 13:22:35 2007 +0100
@@ -30,12 +30,18 @@
TARGET = SUB_TARGET
CAN_DRIVER = SUB_CAN_DRIVER
TIMERS_DRIVER = SUB_TIMERS_DRIVER
+ENABLE_LSS = SUB_ENABLE_LSS
INCLUDES = -I../include -I../include/$(TARGET) -I../include/$(TIMERS_DRIVER) -I../drivers/$(TARGET)
OBJS = $(TARGET)_objacces.o $(TARGET)_lifegrd.o $(TARGET)_sdo.o\
$(TARGET)_pdo.o $(TARGET)_sync.o $(TARGET)_nmtSlave.o $(TARGET)_nmtMaster.o $(TARGET)_states.o $(TARGET)_timer.o $(TARGET)_dcf.o $(TARGET)_emcy.o
+
+ifeq ($(ENABLE_LSS),1)
+OBJS += $(TARGET)_lss.o
+endif
+
# # # # Target specific paramters # # # #
ifeq ($(TARGET),hcs12)
--- a/src/lifegrd.c Fri Dec 14 16:32:38 2007 +0100
+++ b/src/lifegrd.c Mon Dec 17 13:22:35 2007 +0100
@@ -133,6 +133,9 @@
** NMTable[bus_id][nodeId] = Pre_operational
*/
MSG_WAR(0x3100, "The NMT is a bootup from node : ", nodeId);
+
+ /* call post SlaveBootup with NodeId */
+ (*d->post_SlaveBootup)(nodeId);
}
if( d->NMTable[nodeId] != Unknown_state ) {
@@ -250,3 +253,4 @@
** @param heartbeatID
**/
void _heartbeatError(UNS8 heartbeatID){}
+void _post_SlaveBootup(UNS8 SlaveID){}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lss.c Mon Dec 17 13:22:35 2007 +0100
@@ -0,0 +1,662 @@
+/*
+This file is part of CanFestival, a library implementing CanOpen Stack.
+
+
+Copyright (C): Jorge Berzosa
+
+
+See COPYING file for copyrights details.
+
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+
+This library 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
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+/*!
+** @file lss.c
+** @author Jorge Berzosa
+** @date Mon Oct 22 05:44:32 2007
+**
+** @brief
+**
+**
+*/
+
+#ifdef CO_ENABLE_LSS
+
+#include "data.h"
+#include "lss.h"
+#include "canfestival.h"
+
+#define LSS_TIMEOUT_MS (TIMEVAL)1000 /* ms */
+
+/* Returns the LSS ident field from a Message struct */
+#define getLSSIdent(msg) ((msg->data[4] << 24) | (msg->data[3] << 16) | (msg->data[2] << 8) | (msg->data[1]))
+
+/* Returns the LSS switch delay field from a Message struct */
+#define getLSSDelay(msg) ((msg->data[2] << 8) | (msg->data[1]))
+
+/* Returns the LSS FastScan BitCheck field from a Message struct */
+#define getLSSBitCheck(msg) msg->data[5]
+
+/* Returns the LSS FastScan LSSSub field from a Message struct */
+#define getLSSSub(msg) msg->data[6]
+
+/* Returns the LSS FastScan LSSNext field from a Message struct */
+#define getLSSNext(msg) msg->data[7]
+
+/* Prototypes for internals functions */
+void LssAlarm(CO_Data* d, UNS32 id);
+
+#define StopLSS_TIMER(id){\
+ MSG_WAR(0x3D01, "StopLSS_TIMER for timer : ", id);\
+ d->lss_transfer.timers[id] = DelAlarm(d->lss_transfer.timers[id]);}
+
+#define StartLSS_MSG_TIMER(){\
+ MSG_WAR(0x3D02, "StartLSS_TIMER for MSG_TIMER",0);\
+ d->lss_transfer.timers[LSS_MSG_TIMER] = SetAlarm(d,LSS_MSG_TIMER,&LssAlarm,MS_TO_TIMEVAL(LSS_TIMEOUT_MS),0);}
+
+#define StartLSS_SDELAY_TIMER(){\
+ MSG_WAR(0x3D03, "StartLSS_TIMER for SDELAY_TIMER",0);\
+ d->lss_transfer.timers[LSS_SWITCH_DELAY_TIMER] = SetAlarm(d,LSS_SWITCH_DELAY_TIMER,&LssAlarm,MS_TO_TIMEVAL(d->lss_transfer.switchDelay),MS_TO_TIMEVAL(d->lss_transfer.switchDelay));}
+
+
+/*!
+**
+**
+** @param d
+** @param id
+**/
+//struct timeval current_time,init_time;
+void LssAlarm(CO_Data* d, UNS32 id)
+{
+ /*unsigned long time_period;
+
+ gettimeofday(¤t_time,NULL);
+ time_period=(current_time.tv_sec - init_time.tv_sec)* 1000000 + current_time.tv_usec - init_time.tv_usec;
+ printf("%3ld.%3ld.%3ld --",time_period/1000000,(time_period%1000000)/1000,time_period%1000);*/
+
+ switch(id){
+ case LSS_MSG_TIMER:
+ MSG_ERR(0x1D04, "LSS timeout. LSS response not received.", 0);
+ MSG_WAR(0x2D05, "LSS timeout command specifier : ", d->lss_transfer.command);
+
+ StopLSS_TIMER(LSS_MSG_TIMER);
+ /* Set aborted state */
+ d->lss_transfer.state = LSS_ABORTED_INTERNAL;
+ /* Call the user function to inform of the problem.*/
+ if(d->lss_transfer.Callback){
+ /*If there is a callback, it is responsible of the error*/
+ (*d->lss_transfer.Callback)(d,d->lss_transfer.command);
+ }
+ break;
+ case LSS_SWITCH_DELAY_TIMER:
+ /* The first switch_delay period has expired. Store the node state, change it
+ * so no CAN messages will be sent or received, call the ChangeBaudRate function*/
+ if(d->lss_transfer.switchDelayState==SDELAY_FIRST){
+ MSG_WAR(0x3D06, "LSS switch delay first period expired",0);
+ d->lss_transfer.switchDelayState=SDELAY_SECOND;
+ //d->lss_transfer.currentState=getState(d);
+ //setState(d, LssTimingDelay);
+ (*d->lss_ChangeBaudRate)(d->lss_transfer.baudRate);
+ }
+ else{ /* d->lss_transfer.switchDelayState==SDELAY_SECOND */
+ MSG_WAR(0x3D07, "LSS switch delay second period expired",0);
+ d->lss_transfer.switchDelayState=SDELAY_OFF;
+ StopLSS_TIMER(LSS_SWITCH_DELAY_TIMER);
+
+ setState(d, d->lss_transfer.currentState);
+ }
+ break;
+ }
+}
+
+/*!
+**
+**
+** @param d
+**/
+void startLSS(CO_Data* d)
+{
+ /*MSG_WAR(0x3D09, "LSS services started",0);*/
+}
+
+/*!
+**
+**
+** @param d
+**/
+void stopLSS(CO_Data* d)
+{
+ /*MSG_WAR(0x3D09, "LSS services stopped",0);*/
+}
+
+/*!
+**
+**
+** @param d
+** @param cob_id
+**
+** @return
+**/
+UNS8 sendSlaveLSSMessage(CO_Data* d, UNS8 command,void *dat1,void *dat2)
+{
+ Message m;
+ UNS8 i;
+
+ if (!d->CurrentCommunicationState.csLSS){
+ MSG_WAR(0x2D0A, "unable to send the LSS message (not in stop or pre-op mode", d->nodeState);
+ return 0;
+ }
+
+ for(i=1;i<8;i++)m.data[i]=0;
+ m.len = 8;
+ m.rtr = NOT_A_REQUEST;
+ m.data[0]=command;
+ m.cob_id.w=SLSS_ADRESS;
+
+ /* Tha data sent with the msg depends on the command */
+ switch(command){
+ case LSS_INQ_NODE_ID: /* Inquire Node-ID */
+ m.data[1]=*(UNS8 *)dat1;
+ break;
+ case LSS_CONF_NODE_ID: /* Configure Node-ID */
+ case LSS_CONF_BIT_TIMING: /* Configure Bit Timing Parameters */
+ case LSS_CONF_STORE: /* Store Configured Parameters */
+ m.data[1]=*(UNS8 *)dat1;
+ m.data[2]=*(UNS8 *)dat2;
+ break;
+ case LSS_INQ_VENDOR_ID: /* Inquire Identity Vendor-ID */
+ case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
+ case LSS_INQ_REV_NUMBER: /* Inquire Identity Revision-Number */
+ case LSS_INQ_SERIAL_NUMBER: /* Inquire Identity Serial-Number */
+ m.data[1]=(UNS8)(*(UNS32*)dat1 & 0xFF);
+ m.data[2]=(UNS8)(*(UNS32*)dat1>>8 & 0xFF);
+ m.data[3]=(UNS8)(*(UNS32*)dat1>>16 & 0xFF);
+ m.data[4]=(UNS8)(*(UNS32*)dat1>>24 & 0xFF);
+ break;
+ case LSS_SM_SELECTIVE_RESP: /* Switch Mode Selective response*/
+ case LSS_IDENT_SLAVE: /* LSS Identify Slave */
+ case LSS_IDENT_NON_CONF_SLAVE: /* LSS identify non-configured remote slave */
+ break;
+ default:
+ MSG_ERR(0x1D0B, "send Slave LSS command not implemented", command);
+ return 0xFF;
+ break;
+ }
+
+ return canSend(d->canHandle,&m);
+}
+
+/*!
+**
+**
+** @param d
+** @param cob_id
+**
+** @return
+**/
+UNS8 sendMasterLSSMessage(CO_Data* d, UNS8 command,void *dat1,void *dat2)
+{
+ Message m;
+ UNS8 i;
+
+ for(i=1;i<8;i++)m.data[i]=0;
+ m.len = 8;
+ m.rtr = NOT_A_REQUEST;
+ m.data[0]=command;
+ m.cob_id.w=MLSS_ADRESS;
+
+ /* Tha data sent with the msg depends on the command */
+ switch(command){
+ case LSS_SM_GLOBAL: /* Switch Mode Global */
+ d->lss_transfer.state=LSS_FINISHED;
+ case LSS_CONF_NODE_ID: /* Configure Node-ID */
+ m.data[1]=*(UNS8 *)dat1;
+ break;
+ case LSS_CONF_BIT_TIMING: /* Configure Bit Timing Parameters */
+ m.data[1]=*(UNS8 *)dat1;
+ m.data[2]=*(UNS8 *)dat2;
+ break;
+ case LSS_CONF_ACT_BIT_TIMING: /* Activate Bit Timing Parameters */
+ m.data[1]=(UNS8)(*(UNS32*)dat1 & 0xFF);
+ m.data[2]=(UNS8)(*(UNS32*)dat1>>8 & 0xFF);
+ break;
+ case LSS_SM_SELECTIVE_VENDOR: /* Switch Mode Selective */
+ case LSS_SM_SELECTIVE_PRODUCT:
+ case LSS_SM_SELECTIVE_REVISION:
+ case LSS_SM_SELECTIVE_SERIAL:
+ case LSS_IDENT_REMOTE_VENDOR: /* LSS Identify Remote Slaves */
+ case LSS_IDENT_REMOTE_PRODUCT:
+ case LSS_IDENT_REMOTE_REV_LOW:
+ case LSS_IDENT_REMOTE_REV_HIGH:
+ case LSS_IDENT_REMOTE_SERIAL_LOW:
+ case LSS_IDENT_REMOTE_SERIAL_HIGH:
+ m.data[1]=(UNS8)(*(UNS32*)dat1 & 0xFF);
+ m.data[2]=(UNS8)(*(UNS32*)dat1>>8 & 0xFF);
+ m.data[3]=(UNS8)(*(UNS32*)dat1>>16 & 0xFF);
+ m.data[4]=(UNS8)(*(UNS32*)dat1>>24 & 0xFF);
+ break;
+ case LSS_CONF_STORE: /* Store Configured Parameters */
+ case LSS_IDENT_REMOTE_NON_CONF: /* LSS identify non-configured remote slave */
+ case LSS_INQ_VENDOR_ID: /* Inquire Identity Vendor-ID */
+ case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
+ case LSS_INQ_REV_NUMBER: /* Inquire Identity Revision-Number */
+ case LSS_INQ_SERIAL_NUMBER: /* Inquire Identity Serial-Number */
+ case LSS_INQ_NODE_ID: /* Inquire Node-ID */
+ break;
+ case LSS_IDENT_FASTSCAN:
+ m.data[1]=(UNS8)(d->lss_transfer.IDNumber & 0xFF);
+ m.data[2]=(UNS8)(d->lss_transfer.IDNumber>>8 & 0xFF);
+ m.data[3]=(UNS8)(d->lss_transfer.IDNumber>>16 & 0xFF);
+ m.data[4]=(UNS8)(d->lss_transfer.IDNumber>>24 & 0xFF);
+ m.data[5]=d->lss_transfer.BitChecked;
+ m.data[6]=d->lss_transfer.LSSSub;
+ m.data[7]=d->lss_transfer.LSSNext;
+ break;
+ default:
+ MSG_ERR(0x1D0C, "send Master LSS command not implemented", command);
+ return 0xFF;
+ break;
+ }
+
+ return canSend(d->canHandle,&m);
+}
+
+/*!
+**
+**
+** @param d
+** @param cob_id
+**
+** @return
+**/
+UNS8 sendLSS(CO_Data* d, UNS8 command,void *dat1,void *dat2)
+{
+ UNS8 res=1;
+
+ /* Tha data sent with the msg depends on the command and if the sender is a master or a slave */
+ if (*(d->iam_a_slave)){
+ res = sendSlaveLSSMessage(d, command,dat1,dat2);
+ }
+ else {/* It is a Master */
+ res = sendMasterLSSMessage(d, command,dat1,dat2);
+ }
+ return res ;
+}
+
+
+/*!
+**
+**
+** @param d
+** @param m
+**
+** @return
+**/
+UNS8 proceedLSS_Master(CO_Data* d, Message* m )
+{
+ UNS8 msg_cs;
+ UNS32 Dat1=0;
+ UNS8 Dat2=0;
+
+ MSG_WAR(0x3D0D, "MasterLSS proceedLSS; command ", m->data[0]);
+ StopLSS_TIMER(LSS_MSG_TIMER);
+ /* Set state */
+ d->lss_transfer.state = LSS_FINISHED;
+
+ switch(msg_cs=m->data[0]){
+ case LSS_INQ_NODE_ID: /* Inquire Node-ID */
+ Dat1=m->data[1];
+ break;
+ case LSS_CONF_NODE_ID: /* Configure Node-ID */
+ case LSS_CONF_BIT_TIMING: /* Configure Bit Timing Parameters */
+ case LSS_CONF_STORE: /* Store Configured Parameters */
+ Dat1=m->data[1];
+ Dat2=m->data[2];
+ break;
+ case LSS_INQ_VENDOR_ID: /* Inquire Identity Vendor-ID */
+ case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
+ case LSS_INQ_REV_NUMBER: /* Inquire Identity Revision-Number */
+ case LSS_INQ_SERIAL_NUMBER: /* Inquire Identity Serial-Number */
+ Dat1=getLSSIdent(m);
+ break;
+ case LSS_IDENT_SLAVE: /* LSS Identify Slave */
+ /*if(d->lss_transfer.command==LSS_IDENT_FASTSCAN){
+ * ************ TODO *******************
+ }*/
+ break;
+ case LSS_SM_SELECTIVE_RESP: /* Switch Mode Selective response */
+ case LSS_IDENT_NON_CONF_SLAVE: /* LSS identify non-configured remote slave */
+ break;
+ default:
+ MSG_ERR(0x1D0E, "Master LSS command not implemented", msg_cs);
+ return 0xFF;
+ break;
+ }
+
+ d->lss_transfer.dat1=Dat1;
+ d->lss_transfer.dat2=Dat2;
+ /* If there is a callback, it is responsible of the received response */
+ if(d->lss_transfer.Callback)
+ (*d->lss_transfer.Callback)(d,msg_cs);
+
+ return 0;
+}
+
+/*!
+**
+**
+** @param d
+** @param m
+**
+** @return
+**/
+UNS8 proceedLSS_Slave(CO_Data* d, Message* m )
+{
+ UNS8 msg_cs;
+
+ MSG_WAR(0x3D0F, "SlaveLSS proceedLSS; command ", m->data[0]);
+
+ switch(msg_cs=m->data[0]){
+ case LSS_SM_GLOBAL: /* Switch Mode Global */
+ /* if there is not a mode change break*/
+ if(m->data[1] == d->lss_transfer.mode){
+ MSG_WAR(0x3D10, "SlaveLSS already in the mode ", m->data[1]);
+ break;
+ }
+
+ if(m->data[1]==LSS_CONFIGURATION_MODE) {
+ MSG_WAR(0x3D11, "SlaveLSS switching to configuration mode ", 0);
+ /* Store the NodeId in case it will be changed */
+ d->lss_transfer.nodeID=getNodeId(d);
+ d->lss_transfer.mode=LSS_CONFIGURATION_MODE;
+ }
+ else if(m->data[1]==LSS_WAITING_MODE){
+ MSG_WAR(0x3D12, "SlaveLSS switching to operational mode ", 0);
+
+ if(d->lss_transfer.switchDelayState==SDELAY_OFF){
+ /* If the nodeID has changed update it and put the node state to Initialisation. */
+ if(d->lss_transfer.nodeID!=getNodeId(d)){
+ MSG_WAR(0x3D13, "The node Id has changed. Reseting to Initialisation state",0);
+ setNodeId(d, d->lss_transfer.nodeID);
+ setState(d, Initialisation);
+ }
+ }
+ d->lss_transfer.mode=LSS_WAITING_MODE;
+ }
+ break;
+ case LSS_CONF_NODE_ID: /* Configure Node-ID */
+ {
+ UNS8 error_code=0;
+ UNS8 spec_error=0;
+
+ if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE){
+ if(m->data[1]>127 && m->data[1]!=0xFF){
+ MSG_ERR(0x1D14, "NodeID out of range",0);
+ error_code=1; /* NodeID out of range */
+ }
+ else{
+ d->lss_transfer.nodeID=m->data[1];
+ }
+ }
+ else{
+ MSG_ERR(0x1D15, "SlaveLSS not in configuration mode",0);
+ error_code=0xFF;
+ }
+ sendSlaveLSSMessage(d,msg_cs,&error_code,&spec_error);
+ }
+ break;
+ case LSS_CONF_BIT_TIMING: /* Configure Bit Timing Parameters */
+ {
+ UNS8 error_code=0;
+ UNS8 spec_error=0;
+
+ if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE){
+ /* Change the baud rate only if the function lss_ChangeBaudRate
+ * has been implemented. If not send an error.
+ */
+ if(d->lss_ChangeBaudRate){
+ /* If a baud rate is not supported just comment the line. */
+ switch(m->data[2]){
+ case 0x00:d->lss_transfer.baudRate="1M";break;
+ case 0x01:d->lss_transfer.baudRate="800K";break;
+ case 0x02:d->lss_transfer.baudRate="500K";break;
+ case 0x03:d->lss_transfer.baudRate="250K";break;
+ case 0x04:d->lss_transfer.baudRate="125K";break;
+ case 0x05:d->lss_transfer.baudRate="100K";break;
+ case 0x06:d->lss_transfer.baudRate="50K";break;
+ case 0x07:d->lss_transfer.baudRate="20K";break;
+ case 0x08:d->lss_transfer.baudRate="10K";break;
+ default:
+ MSG_ERR(0x1D16, "Baud rate not supported",0);
+ error_code=0xFF; /* Baud rate not supported*/
+ break;
+ }
+ }
+ else
+ {
+ MSG_ERR(0x1D17, "Bit timing not supported",0);
+ error_code=0x01; /* bit timing not supported */
+ }
+ }
+ else{
+ MSG_ERR(0x1D18, "SlaveLSS not in configuration mode",0);
+ error_code=0xFF;
+ }
+
+ sendSlaveLSSMessage(d,msg_cs,&error_code,&spec_error);
+ }
+ break;
+ case LSS_CONF_ACT_BIT_TIMING: /* Activate Bit Timing Parameters */
+
+ if(d->lss_transfer.mode!=LSS_CONFIGURATION_MODE){
+ MSG_ERR(0x1D19, "SlaveLSS not in configuration mode",0);
+ break;
+ }
+
+ if(d->lss_transfer.baudRate!="none"){
+ d->lss_transfer.switchDelay=getLSSDelay(m);
+ MSG_WAR(0x3D1A, "Slave Switch Delay set to: ",d->lss_transfer.switchDelay);
+ d->lss_transfer.switchDelayState=SDELAY_FIRST;
+ d->lss_transfer.currentState=getState(d);
+ setState(d, LssTimingDelay);
+ StartLSS_SDELAY_TIMER();
+ }
+ break;
+ case LSS_CONF_STORE: /* Store Configured Parameters */
+ {
+ UNS8 error_code=0;
+ UNS8 spec_error=0;
+
+ if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE){
+ if(d->lss_StoreConfiguration){
+ /* call lss_StoreConfiguration with NodeId */
+ (*d->lss_StoreConfiguration)(&error_code,&spec_error);
+ }
+ else{
+ MSG_ERR(0x1D1B, "Store configuration not supported",0);
+ error_code=1; /* store configuration is not supported */
+ }
+ }
+ else{
+ MSG_ERR(0x1D1C, "SlaveLSS not in configuration mode",0);
+ error_code=0xFF;
+ }
+ sendSlaveLSSMessage(d,msg_cs,&error_code,&spec_error);
+ }
+ break;
+ case LSS_SM_SELECTIVE_VENDOR: /* Switch Mode Selective */
+ case LSS_SM_SELECTIVE_PRODUCT:
+ case LSS_SM_SELECTIVE_REVISION:
+ case LSS_SM_SELECTIVE_SERIAL:
+ {
+ UNS32 errorCode;
+ const indextable *ptrTable;
+ ODCallback_t *Callback;
+ UNS32 _SpecificNodeInfo;
+
+ if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE)
+ {
+ MSG_ERR(0x1D1D, "Switch Mode Selective only supported in operational mode",0);
+ break;
+ }
+
+ _SpecificNodeInfo=getLSSIdent(m);
+
+ ptrTable = (*d->scanIndexOD)(0x1018, &errorCode, &Callback);
+ if(_SpecificNodeInfo==*(UNS32*)ptrTable->pSubindex[msg_cs-(LSS_SM_SELECTIVE_VENDOR-1)].pObject){
+
+ d->lss_transfer.addr_sel_match|=(0x01<<(msg_cs-LSS_SM_SELECTIVE_VENDOR));
+ /* If all the fields has been set */
+ if(d->lss_transfer.addr_sel_match==0x0F){
+
+ MSG_WAR(0x3D1E, "SlaveLSS switching to configuration mode ", 0);
+ d->lss_transfer.addr_sel_match=0;
+ d->lss_transfer.nodeID=getNodeId(d);
+ d->lss_transfer.mode=LSS_CONFIGURATION_MODE;
+
+ sendSlaveLSSMessage(d,LSS_SM_SELECTIVE_RESP,0,0);
+ }
+ }
+ else {
+ MSG_WAR(0x3D1F, "LSS identity field doesn't match ", _SpecificNodeInfo);
+ d->lss_transfer.addr_sel_match=0;
+ }
+ }
+ break;
+ case LSS_IDENT_REMOTE_VENDOR: /* LSS Identify Remote Slaves */
+ case LSS_IDENT_REMOTE_PRODUCT:
+ case LSS_IDENT_REMOTE_REV_LOW:
+ case LSS_IDENT_REMOTE_REV_HIGH:
+ case LSS_IDENT_REMOTE_SERIAL_LOW:
+ case LSS_IDENT_REMOTE_SERIAL_HIGH:
+ {
+ UNS32 errorCode;
+ const indextable *ptrTable;
+ ODCallback_t *Callback;
+ UNS32 _SpecificNodeInfo;
+
+ _SpecificNodeInfo=getLSSIdent(m);
+
+ ptrTable = (*d->scanIndexOD)(0x1018, &errorCode, &Callback);
+
+ /* Check if the data match the identity object. */
+ switch(msg_cs){
+ case LSS_IDENT_REMOTE_VENDOR:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo == *(UNS32*)ptrTable->pSubindex[1].pObject)? d->lss_transfer.addr_ident_match|0x01:0; break;
+ case LSS_IDENT_REMOTE_PRODUCT:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo == *(UNS32*)ptrTable->pSubindex[2].pObject)? d->lss_transfer.addr_ident_match|0x02:0; break;
+ case LSS_IDENT_REMOTE_REV_LOW:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo <= *(UNS32*)ptrTable->pSubindex[3].pObject)? d->lss_transfer.addr_ident_match|0x04:0; break;
+ case LSS_IDENT_REMOTE_REV_HIGH:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo >= *(UNS32*)ptrTable->pSubindex[3].pObject)? d->lss_transfer.addr_ident_match|0x08:0; break;
+ case LSS_IDENT_REMOTE_SERIAL_LOW:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo <= *(UNS32*)ptrTable->pSubindex[4].pObject)? d->lss_transfer.addr_ident_match|0x10:0; break;
+ case LSS_IDENT_REMOTE_SERIAL_HIGH:d->lss_transfer.addr_ident_match=(_SpecificNodeInfo >= *(UNS32*)ptrTable->pSubindex[4].pObject)? d->lss_transfer.addr_ident_match|0x20:0; break;
+ }
+ /* If all the fields has been set.. */
+ if(d->lss_transfer.addr_ident_match==0x3F){
+ MSG_WAR(0x3D20, "SlaveLSS identified ", 0);
+ d->lss_transfer.addr_ident_match=0;
+ sendSlaveLSSMessage(d,LSS_IDENT_SLAVE,0,0);
+ }
+ else if(d->lss_transfer.addr_ident_match==0){
+ MSG_WAR(0x3D21, "LSS identify field doesn't match ", _SpecificNodeInfo);
+ }
+ }
+ break;
+ case LSS_IDENT_REMOTE_NON_CONF: /* LSS identify non-configured remote slave */
+ {
+ if(getNodeId(d)==0xFF){
+ MSG_WAR(0x3D22, "SlaveLSS non-configured ", 0);
+ sendSlaveLSSMessage(d,LSS_IDENT_NON_CONF_SLAVE,0,0);
+ }
+ else{
+ MSG_WAR(0x3D23, "SlaveLSS already configured ", 0);
+ }
+ }
+ break;
+ case LSS_INQ_VENDOR_ID: /* Inquire Identity Vendor-ID */
+ case LSS_INQ_PRODUCT_CODE: /* Inquire Identity Product-Code */
+ case LSS_INQ_REV_NUMBER: /* Inquire Identity Revision-Number */
+ case LSS_INQ_SERIAL_NUMBER: /* Inquire Identity Serial-Number */
+ if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE)
+ {
+
+ UNS32 errorCode;
+ const indextable *ptrTable;
+ ODCallback_t *Callback;
+ UNS32 _SpecificNodeInfo;
+
+ ptrTable = (*d->scanIndexOD)(0x1018, &errorCode, &Callback);
+ _SpecificNodeInfo=*(UNS32*)ptrTable->pSubindex[msg_cs-(LSS_INQ_VENDOR_ID-1)].pObject;
+ MSG_WAR(0x3D24, "SlaveLSS identity field inquired ", _SpecificNodeInfo);
+
+ sendSlaveLSSMessage(d,msg_cs,&_SpecificNodeInfo,0);
+ }
+ break;
+ case LSS_INQ_NODE_ID: /* Inquire Node-ID */
+ if(d->lss_transfer.mode==LSS_CONFIGURATION_MODE)
+ {
+ UNS8 NodeID;
+
+ NodeID=getNodeId(d);
+ MSG_WAR(0x3D25, "SlaveLSS Node ID inquired ", NodeID);
+ sendSlaveLSSMessage(d,msg_cs,&NodeID,0);
+ }
+ else{
+ MSG_ERR(0x1D26, "SlaveLSS not in configuration mode",0);
+ }
+ break;
+ case LSS_IDENT_FASTSCAN:
+ {
+ /******* TODO *******/
+ }
+ break;
+ default:
+ MSG_ERR(0x1D27, "SlaveLSS command not implemented", msg_cs);
+ return 0xFF;
+ break;
+ }
+
+ return 0;
+}
+
+UNS8 configNetworkNode(CO_Data* d, UNS8 command, void *dat1, void* dat2)
+{
+ return sendMasterLSSMessage(d,command,dat1,dat2);
+}
+
+UNS8 configNetworkNodeCallBack (CO_Data* d, UNS8 command, void *dat1, void* dat2, LSSCallback_t Callback)
+{
+ d->lss_transfer.state=LSS_TRANS_IN_PROGRESS;
+ d->lss_transfer.Callback=Callback;
+ d->lss_transfer.command=command;
+
+ StopLSS_TIMER(LSS_MSG_TIMER);
+ StartLSS_MSG_TIMER();
+
+ return sendMasterLSSMessage(d,command,dat1,dat2);
+}
+
+UNS8 getConfigResultNetworkNode (CO_Data* d, UNS8 command, UNS32* dat1, UNS8* dat2)
+{
+ *dat1=d->lss_transfer.dat1;
+ *dat2=d->lss_transfer.dat2;
+ return d->lss_transfer.state;
+}
+
+//void _lss_StoreConfiguration(UNS8 *error, UNS8 *spec_error){printf("_lss_StoreConfiguration\n");}
+//void _lss_ChangeBaudRate(char *BaudRate){printf("_lss_ChangeBaudRate\n");}
+
+#endif
--- a/src/nmtSlave.c Fri Dec 14 16:32:38 2007 +0100
+++ b/src/nmtSlave.c Mon Dec 17 13:22:35 2007 +0100
@@ -98,6 +98,10 @@
{
Message m;
+#ifdef CO_ENABLE_LSS
+ if(*d->bDeviceNodeId==0xFF)return 0;
+#endif
+
MSG_WAR(0x3407, "Send a Boot-Up msg ", 0);
/* message configuration */
--- a/src/states.c Fri Dec 14 16:32:38 2007 +0100
+++ b/src/states.c Mon Dec 17 13:22:35 2007 +0100
@@ -34,7 +34,9 @@
#include "dcf.h"
#include "nmtSlave.h"
#include "emcy.h"
-
+#ifdef CO_ENABLE_LSS
+#include "lss.h"
+#endif
/** Prototypes for internals functions */
/*!
**
@@ -102,6 +104,19 @@
{
proceedNMTstateChange(d,m);
}
+#ifdef CO_ENABLE_LSS
+ case LSS:
+ if (!d->CurrentCommunicationState.csLSS)break;
+ if ((*(d->iam_a_slave)) && m->cob_id.w==MLSS_ADRESS)
+ {
+ proceedLSS_Slave(d,m);
+ }
+ else if(!(*(d->iam_a_slave)) && m->cob_id.w==SLSS_ADRESS)
+ {
+ proceedLSS_Master(d,m);
+ }
+ break;
+#endif
}
}
@@ -131,6 +146,9 @@
StartOrStop(csEmergency, emergencyInit(d), emergencyStop(d))
StartOrStop(csPDO, PDOInit(d), PDOStop(d))
StartOrStop(csBoot_Up, None, slaveSendBootUp(d))
+#ifdef CO_ENABLE_LSS
+ StartOrStop(csLSS, startLSS(d), stopLSS(d))
+#endif
}
/*!
@@ -147,7 +165,7 @@
switch( newState ){
case Initialisation:
{
- s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0};
+ s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0, 0};
/* This will force a second loop for the state switch */
d->nodeState = Initialisation;
newState = Pre_operational;
@@ -161,7 +179,7 @@
case Pre_operational:
{
- s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 0};
+ s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 0, 1};
d->nodeState = Pre_operational;
newState = Pre_operational;
switchCommunicationState(d, &newCommunicationState);
@@ -180,7 +198,7 @@
case Operational:
if(d->nodeState == Initialisation) return 0xFF;
{
- s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 1};
+ s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 1, 0};
d->nodeState = Operational;
newState = Operational;
switchCommunicationState(d, &newCommunicationState);
@@ -191,13 +209,23 @@
case Stopped:
if(d->nodeState == Initialisation) return 0xFF;
{
- s_state_communication newCommunicationState = {0, 0, 0, 0, 1, 0};
+ s_state_communication newCommunicationState = {0, 0, 0, 0, 1, 0, 1};
d->nodeState = Stopped;
newState = Stopped;
switchCommunicationState(d, &newCommunicationState);
(*d->stopped)();
}
break;
+#ifdef CO_ENABLE_LSS
+ case LssTimingDelay:
+ {
+ s_state_communication newCommunicationState = {0, 0, 0, 0, 0, 0, 0};
+ d->nodeState = LssTimingDelay;
+ newState = LssTimingDelay;
+ switchCommunicationState(d, &newCommunicationState);
+ }
+ break;
+#endif
default:
return 0xFF;
@@ -228,6 +256,15 @@
void setNodeId(CO_Data* d, UNS8 nodeId)
{
UNS16 offset = d->firstIndex->SDO_SVR;
+
+#ifdef CO_ENABLE_LSS
+ if(nodeId==0xFF)
+ {
+ *d->bDeviceNodeId = nodeId;
+ return;
+ }
+#endif
+
if(offset){
/* Adjust COB-ID Client->Server (rx) only id already set to default value*/
if(*(UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + *d->bDeviceNodeId){