]> rtime.felk.cvut.cz Git - CanFestival-3.git/commitdiff
FastScan review
authorgroke6 <groke6>
Fri, 12 Sep 2008 08:54:54 +0000 (08:54 +0000)
committergroke6 <groke6>
Fri, 12 Sep 2008 08:54:54 +0000 (08:54 +0000)
12 files changed:
doc/manual/en/manual.tex
examples/TestMasterSlaveLSS/Master.c
examples/TestMasterSlaveLSS/SlaveA.c
examples/TestMasterSlaveLSS/SlaveA.h
examples/TestMasterSlaveLSS/SlaveB.c
examples/TestMasterSlaveLSS/SlaveB.h
examples/TestMasterSlaveLSS/TestMasterSlaveLSS.c
include/data.h
include/lss.h
src/lss.c
src/nmtSlave.c
src/states.c

index 24b494217ffde60e0e3a40b78258f907c4dd4a4d..f35822eebca1c11564e5c2adf680a2ff27b3fc55 100644 (file)
@@ -122,6 +122,10 @@ Supported features should conform to DS301. V.4.02 13 february 2002.
 
 Only concise DFC is supported.
 
+\subsubsection{DS-305}
+
+LSS services are fully supported although they have to be enabled at compile time. Additionally, FastScan LSS service is also optionally enabled. 
+
 \section{How to start}
 
 \subsection{Host requirements}
@@ -203,6 +207,7 @@ Simplified directory structure.
 ./drivers/hcs12 HCS12 full target interface
 ./examples Examples
 ./examples/TestMasterSlave 2 nodes, NMT SYNC SDO PDO, win32+unix
+./examples/TestMasterSlaveLSS 3 nodes, NMT SYNC SDO PDO LSS, win32+unix
 ./examples/TestMasterMicroMod 1 node, control Peak I/O Module, unix
 ./examples/gene_SYNC_HCS12 Just send periodic SYNC on HCS12
 ./examples/win32test Ask some DS301 infos to a node (win32)
@@ -409,9 +414,21 @@ work with Xenomai or RTAI.
        ./configure --can=vscom
 \end{verbatim}
 The VSCAN API archive will be automatically downloaded and decompressed (unzip required). See \href{http://www.vscom.de/1_1_05.htm}{www.vscom.de} for available adapters.
+
+\subsubsection{LSS services}
+Canfestival optionally supports LSS services but they must be enabled.
+\begin{verbatim}
+       ./configure --enable-lss
+\end{verbatim}
+
+Additionally, the FastScan LSS service can also be enabled.
+\begin{verbatim}
+       ./configure --enable-lss --enable-lss-fs
+\end{verbatim}
+
 \subsection{Testing your CanFestival installation}
 
-\subsection{User space}
+\subsubsection{User space}
 
 Sample provided in /example/TestMasterSlave is installed into your
 system during installation.
@@ -435,8 +452,9 @@ CAN ports. Another example using Peak{\textquotesingle}s dual PCMCIA
        TestMasterSlave -l libcanfestival_can_peak.so -s 40 -m 41
 \end{verbatim}
 
+If the LSS services are enabled the sample provided in /example/TestMasterSlaveLSS will be also installed. It behaves the same as TestMasterSlave except that there are 2 slave nodes without a valid nodeID so the the initializations is done via  the LSS services. If FastScan optional service is enabled the example will use it. 
 
-\subsection{Kernel space}
+\subsubsection{Kernel space}
 
 
 \begin{verbatim}
@@ -985,6 +1003,63 @@ console it'll remove modules from kernel.
   **************************************************************
 \end{verbatim}
 
+\subsection{TestMasterSlaveLSS}
+
+
+\begin{verbatim}
+**************************************************************
+*  TestMasterSlaveLSS                                        *
+*                                                            *
+*  A LSS example for PC. It does implement 3 CanOpen         *
+*  nodes in the same process. A master and 2 slaves. All     *
+*  communicate together, exchanging periodically NMT, SYNC,  *
+*  SDO and PDO. Master configure heartbeat producer time     *
+*  at 1000 ms for the slaves by concise DCF.                 *
+*                                                            *
+*   Usage:                                                   *
+*   ./TestMasterSlaveLSS  [OPTIONS]                          *
+*                                                            *
+*   OPTIONS:                                                 *
+*     -l : Can library ["libcanfestival_can_virtual.so"]     *
+*                                                            *
+*    SlaveA:                                                 *
+*     -a : bus name ["0"]                                    *
+*     -A : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *
+*                                                            *
+*    SlaveB:                                                 *
+*     -b : bus name ["1"]                                    *
+*     -B : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *
+*                                                            *
+*    Master:                                                 *
+*     -m : bus name ["2"]                                    *
+*     -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *
+*                                                            *
+**************************************************************
+\end{verbatim}
+
+The function used to request LSS services is \textit{configNetworkNode}. It works similar to \textit{writeNetworkDict} and its model is the following:
+\begin{verbatim}
+UNS8 configNetworkNode (CO_Data* d, UNS8 command, void *dat1, void* dat2, 
+LSSCallback_t Callback)
+\end{verbatim}
+
+\subsection{FastScan}
+FastScan is a special LSS service that allow the dynamically identification of the slave nodes even if they do not have a valid nodeID. This identification is based on the LSS address, composed by vendor ID, product code, revision number and serial number (refer to the DS305 for more information). The LSS address can be partially known or fully unknown. To represent this fact in Canfestival, we use the structure \textit{lss\_fs\_transfer\_t}. The parameter \textit{FS\_LSS\_ID} is an array of four elements which represents the four elements of the LSS address. The other parameter, \textit{FS\_BitChecked}, is also an array and it represents how many bits of each LSS address element are UNKNOWN. The next example is taken from \textit{TestMasterSlaveLSS}, where only the last two digits (8 bits) of vendor ID and product code are unknown and revision number and serial number are totally unknown. 
+
+\begin{verbatim}
+lss_fs_transfer_t lss_fs;
+/* The VendorID and ProductCode are partialy known, */
+/* except the last two digits (8 bits). */
+lss_fs.FS_LSS_ID[0]=Vendor_ID;
+lss_fs.FS_BitChecked[0]=8;
+lss_fs.FS_LSS_ID[1]=Product_Code;
+lss_fs.FS_BitChecked[1]=8;
+/* serialNumber and RevisionNumber are unknown, */
+/* i.e. the 8 digits (32bits) are unknown. */
+lss_fs.FS_BitChecked[2]=32;
+lss_fs.FS_BitChecked[3]=32;
+res=configNetworkNode(&d,LSS_IDENT_FASTSCAN,&lss_fs,0,CheckLSSAndContinue);
+\end{verbatim}
 
 \section{Developing a new node}
 
index 734b2d3ff6250c20205dc8c5afe6d11496445366..bb078daa9552e5022b93579665276c90f93a2512 100644 (file)
@@ -216,13 +216,16 @@ static void CheckLSSAndContinue(CO_Data* d, UNS8 command)
        
                                /* The slaves are now configured (nodeId and Baudrate) via the LSS services.
                                * Switch the LSS state to WAITING and restart the slaves. */
+                               
+                               /*TODO: change the baud rate of the master!!*/
                                MasterBoard.baudrate="250K";
-       
+                               
+                               
                                printf("Master : Switch Delay period finished. Switching to LSS WAITING state\n");
                                configNetworkNode(d,LSS_SM_GLOBAL,&LSS_mode,0,NULL);
                                
                                printf("Master : Restarting all the slaves\n");
-                               masterSendNMTstateChange (d, 0x00, NMT_Reset_Node);
+                               masterSendNMTstateChange (d, 0x00, NMT_Reset_Comunication);
                                
                                printf("Master : Starting the SYNC producer\n");
                                writeLocalDict( d, /*CO_Data* d*/
@@ -342,9 +345,20 @@ static void ConfigureLSSNode(CO_Data* d)
                        break;
 #ifdef CO_ENABLE_LSS_FS
                case 2: /* LSS=>FastScan */
+               {
+                       lss_fs_transfer_t lss_fs;
                        eprintf("LSS=>FastScan\n");
-                       res=configNetworkNode(&TestMaster_Data,LSS_IDENT_FASTSCAN,0,0,CheckLSSAndContinue);
-                       break;
+                       /* The VendorID and ProductCode are partialy known, except the last two digits (8 bits). */
+                       lss_fs.FS_LSS_ID[0]=Vendor_ID;
+                       lss_fs.FS_BitChecked[0]=8;
+                       lss_fs.FS_LSS_ID[1]=Product_Code;
+                       lss_fs.FS_BitChecked[1]=8;
+                       /* serialNumber and RevisionNumber are unknown, i.e. the 8 digits (32bits) are unknown. */
+                       lss_fs.FS_BitChecked[2]=32;
+                       lss_fs.FS_BitChecked[3]=32;
+                       res=configNetworkNode(&TestMaster_Data,LSS_IDENT_FASTSCAN,&lss_fs,0,CheckLSSAndContinue);
+               }
+               break;
 #else
                case 2: /* LSS=>identify node */
                        eprintf("LSS=>identify node\n");
index 857941f8526a70cf56306bbc29294ac88449f623..9807d54829db9cd2c2513a6d7f73d8cc092c161d 100644 (file)
@@ -81,8 +81,13 @@ void TestSlaveA_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
        eprintf("SlaveA received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
 }
 
+void TestSlaveA_NMT_Slave_Communications_Reset_Callback(CO_Data* d)
+{
+       eprintf("TestSlaveA_NMT_Slave_Communications_Reset_Callback\n");
+}
+
 void TestSlaveA_StoreConfiguration(CO_Data* d, UNS8 *error, UNS8 *spec_error)
 {
-       printf("TestSlaveA_StoreConfiguration\n");
+       eprintf("TestSlaveA_StoreConfiguration\n");
 }
 
index a4eb23b6f98ff908cae066fdbea9d125267dd1a2..be879917066afa100c9c6573c6f6c95bdefbe805 100644 (file)
@@ -13,4 +13,5 @@ void TestSlaveA_post_sync(CO_Data* d);
 void TestSlaveA_post_TPDO(CO_Data* d);
 void TestSlaveA_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
 void TestSlaveA_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
+void TestSlaveA_NMT_Slave_Communications_Reset_Callback(CO_Data* d);
 void TestSlaveA_StoreConfiguration(CO_Data* d, UNS8 *error, UNS8 *spec_error);
index 743f45a82435aa74fed82e81bf354bb5b6ab9fd1..e75137938de930b29a49fb8fb721dffc76a3620d 100644 (file)
@@ -80,8 +80,13 @@ void TestSlaveB_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
        eprintf("SlaveB received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
 }
 
+void TestSlaveB_NMT_Slave_Communications_Reset_Callback(CO_Data* d)
+{
+       eprintf("TestSlaveB_NMT_Slave_Communications_Reset_Callback\n");
+}
+
 void TestSlaveB_StoreConfiguration(CO_Data* d, UNS8 *error, UNS8 *spec_error)
 {
-       printf("TestSlaveB_StoreConfiguration\n");
+       eprintf("TestSlaveB_StoreConfiguration\n");
 }
 
index 7b4440417574716b552a91331b30c634bf93c948..79ea7eba76f8c1c6ed54218011a971bc83f292a5 100644 (file)
@@ -13,4 +13,5 @@ void TestSlaveB_post_sync(CO_Data* d);
 void TestSlaveB_post_TPDO(CO_Data* d);
 void TestSlaveB_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
 void TestSlaveB_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
+void TestSlaveB_NMT_Slave_Communications_Reset_Callback(CO_Data* d);
 void TestSlaveB_StoreConfiguration(CO_Data* d, UNS8 *error, UNS8 *spec_error);
index ec21d33547431633f446af5d51c585eb728fd557..c50bafcc5612595219b00b8adb7ff5e3e7d85daf 100644 (file)
@@ -66,24 +66,24 @@ void help(void)
   printf("*  nodes in the same process. A master and 2 slaves. All     *\n");
   printf("*  communicate together, exchanging periodically NMT, SYNC,  *\n");
   printf("*  SDO and PDO. Master configure heartbeat producer time     *\n");
-  printf("*  at 0 ms for slave node-id 0x02 and 0x03 by concise DCF.   *\n");                                  
+  printf("*  at 1000 ms for the slaves by concise DCF.                 *\n");                                  
   printf("*                                                            *\n");
   printf("*   Usage:                                                   *\n");
   printf("*   ./TestMasterSlaveLSS  [OPTIONS]                          *\n");
   printf("*                                                            *\n");
   printf("*   OPTIONS:                                                 *\n");
-  printf("*     -l : Can library [\"libcanfestival_can_virtual.so\"]   *\n");
+  printf("*     -l : Can library [\"libcanfestival_can_virtual.so\"]     *\n");
   printf("*                                                            *\n");
   printf("*    SlaveA:                                                 *\n");
-  printf("*     -a : bus name [\"0\"]                                  *\n");
+  printf("*     -a : bus name [\"0\"]                                    *\n");
   printf("*     -A : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
   printf("*                                                            *\n");
-   printf("*    SlaveB:                                                *\n");
-  printf("*     -b : bus name [\"1\"]                                  *\n");
+  printf("*    SlaveB:                                                 *\n");
+  printf("*     -b : bus name [\"1\"]                                    *\n");
   printf("*     -B : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
   printf("*                                                            *\n");
   printf("*    Master:                                                 *\n");
-  printf("*     -m : bus name [\"2\"]                                  *\n");
+  printf("*     -m : bus name [\"2\"]                                    *\n");
   printf("*     -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
   printf("*                                                            *\n");
   printf("**************************************************************\n");
@@ -236,7 +236,8 @@ int main(int argc,char **argv)
                TestSlaveA_Data.post_TPDO = TestSlaveA_post_TPDO;
                TestSlaveA_Data.storeODSubIndex = TestSlaveA_storeODSubIndex;
                TestSlaveA_Data.post_emcy = TestSlaveA_post_emcy;
-               /* in this example the slave doesn't support Store configuration*/
+               /* in this example the slave doesn't implement NMT_Slave_Communications_Reset_Callback */
+               //TestSlaveA_Data.NMT_Slave_Communications_Reset_Callback = TestSlaveA_NMT_Slave_Communications_Reset_Callback;
                TestSlaveA_Data.lss_StoreConfiguration = TestSlaveA_StoreConfiguration;
 
                if(!canOpen(&SlaveBoardA,&TestSlaveA_Data)){
@@ -256,6 +257,7 @@ int main(int argc,char **argv)
                TestSlaveB_Data.post_TPDO = TestSlaveB_post_TPDO;
                TestSlaveB_Data.storeODSubIndex = TestSlaveB_storeODSubIndex;
                TestSlaveB_Data.post_emcy = TestSlaveB_post_emcy;
+               TestSlaveB_Data.NMT_Slave_Communications_Reset_Callback = TestSlaveB_NMT_Slave_Communications_Reset_Callback;
                TestSlaveB_Data.lss_StoreConfiguration = TestSlaveB_StoreConfiguration;
 
                if(!canOpen(&SlaveBoardB,&TestSlaveB_Data)){
index ceba1702573c438236bc6a13b6d499255f5e1c35..0cd0a43845b4a40ff73cfca67ba97dfce2ebf040 100644 (file)
@@ -157,7 +157,8 @@ struct struct_CO_Data {
                0,                                              /* LSSNext */\
                0,                                              /* LSSPos */\
                LSS_FS_RESET,                   /* FastScan_SM */\
-               -1                                              /* timerFS */
+               -1,                                             /* timerFS */\
+               {{0,0,0,0},{0,0,0,0}}   /* lss_fs_transfer */
 #else
 #define lss_fs_Initializer
 #endif         
index f9285e88992e9a7d56b735a06257d50ea6955a60..5b08635efad9bf397ab1a3bf93071d67bf14ec7b 100644 (file)
@@ -82,6 +82,15 @@ struct struct_lss_transfer;
 
 //#include "timer.h"
 
+#ifdef CO_ENABLE_LSS_FS
+struct struct_lss_fs_transfer {
+       UNS32 FS_LSS_ID[4];
+       UNS8 FS_BitChecked[4];
+};
+
+typedef struct struct_lss_fs_transfer lss_fs_transfer_t;
+#endif
+
 /* The Transfer structure
 * Used to store the different fields of the internal state of the LSS  
 */
@@ -130,6 +139,10 @@ struct struct_lss_transfer {
   TIMER_HANDLE timerFS;                /* timerFS is automatically incremented when the FastScan service
                                                         * has been requested and reseted to 0 when the protocol ends.
                               */
+#ifdef CO_ENABLE_LSS_FS
+  lss_fs_transfer_t lss_fs_transfer;
+#endif
+  
 #endif                           
 };
 
@@ -139,7 +152,8 @@ typedef struct struct_lss_transfer lss_transfer_t;
 typedef UNS8 lss_transfer_t;
 #endif
   
-  
+
+
 void startLSS(CO_Data* d);
 void stopLSS(CO_Data* d);
 
index 1dee612fa208e86d185c753450d9055f77fe6bbc..2febb62293204279ea44ad4937ec856fcc93f10b 100644 (file)
--- a/src/lss.c
+++ b/src/lss.c
@@ -108,10 +108,13 @@ void LssAlarmMSG(CO_Data* d, UNS32 id)
                if(d->lss_transfer.FastScan_SM==LSS_FS_RESET){
                        /* if at least one node had answered before the timer expired, start the FastScan protocol*/
                        if(d->lss_transfer.LSSanswer!=0){
+                               UNS32 Mask=0xFFFFFFFF;
                                d->lss_transfer.LSSanswer=0;
-                               d->lss_transfer.BitChecked=31;
-                               d->lss_transfer.IDNumber=0;
+                               d->lss_transfer.BitChecked=d->lss_transfer.lss_fs_transfer.FS_BitChecked[0];
+                               Mask=(UNS32)((UNS64)Mask<<(d->lss_transfer.BitChecked+1));
+                               d->lss_transfer.IDNumber=d->lss_transfer.lss_fs_transfer.FS_LSS_ID[0] & Mask;
                                d->lss_transfer.FastScan_SM=LSS_FS_PROCESSING;
+                               //printf("BitChecked=%d, IDNumber=%x MASK=%x\n",d->lss_transfer.BitChecked,d->lss_transfer.IDNumber,Mask);
                                StartLSS_FS_TIMER();
                                sendMasterLSSMessage(d,LSS_IDENT_FASTSCAN,0,0);
                                return;
@@ -126,6 +129,8 @@ void LssAlarmMSG(CO_Data* d, UNS32 id)
                else{
                        /* This should not happen, an error ocurred*/
                        MSG_ERR(0x1D07, "LSS FastScan timeout. FastScan_SM inconsisten state.", d->lss_transfer.FastScan_SM);
+                       d->lss_transfer.state = LSS_ABORTED_INTERNAL;
+                       d->lss_transfer.FastScan_SM=LSS_FS_RESET;
                }
        }
        else
@@ -140,6 +145,9 @@ void LssAlarmMSG(CO_Data* d, UNS32 id)
        MSG_WAR(0x2D0A, "LSS timeout command specifier : ", d->lss_transfer.command);
        /* Set aborted state */
        d->lss_transfer.state = LSS_ABORTED_INTERNAL;
+#ifdef CO_ENABLE_LSS_FS
+       d->lss_transfer.FastScan_SM = LSS_FS_RESET;
+#endif
     }
        
     /* Call the user function to inform of the problem.*/
@@ -220,7 +228,7 @@ void LssAlarmFS(CO_Data* d, UNS32 id)
                else{
                        d->lss_transfer.BitChecked--;
                }
-                       
+               //printf("BitChecked=%d, IDNumber=%x\n",d->lss_transfer.BitChecked,d->lss_transfer.IDNumber);
                d->lss_transfer.LSSanswer=0;
                StartLSS_FS_TIMER();
                sendMasterLSSMessage(d,LSS_IDENT_FASTSCAN,0,0);
@@ -245,11 +253,14 @@ void LssAlarmFS(CO_Data* d, UNS32 id)
                                d->lss_transfer.dat1=0;
                        }
                        else{
+                               UNS32 Mask=0xFFFFFFFF;
                                /* Start with the next LSS-ID[sub] */
                                d->lss_transfer.LSSSub++;
-                               d->lss_transfer.BitChecked=31;
-                               d->lss_transfer.IDNumber=0;
+                               d->lss_transfer.BitChecked=d->lss_transfer.lss_fs_transfer.FS_BitChecked[d->lss_transfer.LSSSub];
+                               Mask=(UNS32)((UNS64)Mask<<(d->lss_transfer.BitChecked+1));
+                               d->lss_transfer.IDNumber=d->lss_transfer.lss_fs_transfer.FS_LSS_ID[d->lss_transfer.LSSSub] & Mask;
                                d->lss_transfer.FastScan_SM=LSS_FS_PROCESSING;
+                               //printf("BitChecked=%d, IDNumber=%x MASK=%x\n",d->lss_transfer.BitChecked,d->lss_transfer.IDNumber,Mask);
                                StartLSS_FS_TIMER();
                                sendMasterLSSMessage(d,LSS_IDENT_FASTSCAN,0,0);
                                return;
@@ -258,8 +269,11 @@ void LssAlarmFS(CO_Data* d, UNS32 id)
                else{
                        /* This should not happen, an error ocurred*/
                        MSG_ERR(0x1D0E, "LSS FastScan timeout. FastScan response not received.", 0);
+                       MSG_ERR(0x1D0E, "There is not any node with LSS_ID# =>", d->lss_transfer.LSSSub);
+                       MSG_ERR(0x1D0E, "with the value =>", d->lss_transfer.IDNumber);
                        /* Set aborted state */
                d->lss_transfer.state = LSS_ABORTED_INTERNAL;
+               d->lss_transfer.FastScan_SM = LSS_FS_RESET;
                }
        }
        break;
@@ -469,6 +483,24 @@ UNS8 sendMasterLSSMessage(CO_Data* d, UNS8 command,void *dat1,void *dat2)
        break;
 #ifdef CO_ENABLE_LSS_FS
   case LSS_IDENT_FASTSCAN:
+               if(d->lss_transfer.FastScan_SM==LSS_FS_RESET){
+                       UNS8 i;
+                        /* Initialize the lss_fs_transfer FastScan parameters */
+                       for(i=0;i<4;i++){
+                               d->lss_transfer.lss_fs_transfer.FS_LSS_ID[i]=(*(lss_fs_transfer_t*)dat1).FS_LSS_ID[i];
+                               d->lss_transfer.lss_fs_transfer.FS_BitChecked[i]=(*(lss_fs_transfer_t*)dat1).FS_BitChecked[i];
+                               /* Adjust BitChecked from 32-1 to 31-0 */
+                               if(d->lss_transfer.lss_fs_transfer.FS_BitChecked[i]>0)d->lss_transfer.lss_fs_transfer.FS_BitChecked[i]--;
+                       }
+                       
+                       d->lss_transfer.IDNumber=0;
+                       d->lss_transfer.BitChecked=128;
+                       d->lss_transfer.LSSSub=0;
+                       d->lss_transfer.LSSNext=0;
+                                       
+                       /* it will generate a response only if it is the start of the FastScan protocol*/
+                       hasResponse=1;
+               }
                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);
@@ -476,8 +508,6 @@ UNS8 sendMasterLSSMessage(CO_Data* d, UNS8 command,void *dat1,void *dat2)
                m.data[5]=d->lss_transfer.BitChecked;
                m.data[6]=d->lss_transfer.LSSSub;
                m.data[7]=d->lss_transfer.LSSNext;
-               /* it will generate a response only if it is the start of the FastScan protocol*/
-               if(d->lss_transfer.FastScan_SM==LSS_FS_RESET)hasResponse=1;
        break;
 #endif
   default:
@@ -645,7 +675,7 @@ UNS8 proceedLSS_Slave(CO_Data* d, Message* m )
                                        setNodeId(d, d->lss_transfer.nodeID);
                                        setState(d, Initialisation);
                                }
-                               else{/* The nodeID will be changed on NMT_Reset Request*/
+                               else{/* The nodeID will be changed on NMT_Reset_Comunication Request*/
                                }
                        }
                        d->lss_transfer.mode=LSS_WAITING_MODE;
index ce69bb8aab7794da1cad8d356666aca45f6d35a3..0ff2ebac5a7ead83bb6bcafd0f370a8168e6b8ed 100644 (file)
@@ -80,22 +80,22 @@ void proceedNMTstateChange(CO_Data* d, Message *m)
 
       case NMT_Reset_Comunication:
          {
-         UNS8 newNodeId = getNodeId(d);
+         UNS8 currentNodeId = getNodeId(d);
          
             if(d->NMT_Slave_Communications_Reset_Callback != NULL)
                d->NMT_Slave_Communications_Reset_Callback(d);
 #ifdef CO_ENABLE_LSS
             // LSS changes NodeId here in case lss_transfer.nodeID doesn't 
             // match current getNodeId()
-            if(newNodeId!=d->lss_transfer.nodeID && newNodeId>0 && newNodeId<=127 )
-               newNodeId = d->lss_transfer.nodeID;
+            if(currentNodeId!=d->lss_transfer.nodeID)
+               currentNodeId = d->lss_transfer.nodeID;
 #endif
 
             // clear old NodeId to make SetNodeId reinitializing
             // SDO, EMCY and other COB Ids
             *d->bDeviceNodeId = 0xFF; 
          
-            setNodeId(d, newNodeId);
+            setNodeId(d, currentNodeId);
          }
          setState(d,Initialisation);
          break;
index 1133de6b0eb006b200d3cbf5721d184a9f6dc27b..c7d5df7eeb680e773ea21a98ea1d9b4c31989512 100644 (file)
@@ -244,12 +244,16 @@ void setNodeId(CO_Data* d, UNS8 nodeId)
   
 #ifdef CO_ENABLE_LSS
   d->lss_transfer.nodeID=nodeId;
-  if(nodeId==0xFF)
-  {
+  if(nodeId==0xFF){
        *d->bDeviceNodeId = nodeId;
        return;
   }
+  else
 #endif
+  if(!(nodeId>0 && nodeId<=127)){
+         MSG_WAR(0x2D01, "Invalid NodeID",nodeId);
+         return;
+  }
 
   if(offset){
     /* Adjust COB-ID Client->Server (rx) only id already set to default value or id not valid (id==0xFF)*/