[dss-commits] digitalSTROM Server branch, master, updated. e3061ebca87df0d068d141f64f58cea02da09d59

git version control dss-commits at forum.digitalstrom.org
Fri Dec 18 14:11:48 CET 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "digitalSTROM Server".

The branch, master has been updated
       via  e3061ebca87df0d068d141f64f58cea02da09d59 (commit)
       via  73c4c8daf429234ea153c6c47a937f2271b9d0d8 (commit)
       via  6bc9a0c648f7c4dffaa0e5549d933dfe0bc43940 (commit)
      from  129a3c74df829e673c3b6ec8962bc40632b1e979 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e3061ebca87df0d068d141f64f58cea02da09d59
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Fri Dec 18 14:10:19 2009 +0100

    Michael Tross: Commucation errors with echos
    
    RS485 interfaces may echo the transmitted data back into the receiver.
    The dSS does not take care of receiving his own packets. If present on
    the hardware, the echo feature should be used to verify the correct
    transmission and improve the communication quality.
    
    Fixes #253

commit 73c4c8daf429234ea153c6c47a937f2271b9d0d8
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Fri Dec 18 14:04:11 2009 +0100

    Michael Tross: Handling of dS485 bus reorg.
    
    Communication failures on the RS485 interface may occur as devices are
    powered on and off, leading to lost packets. In some circumstances this
    may lead to a reorganization of the bus where all devices have to run
    through the initial address allocation phase. The dSS does not detect or
    properly handle this bus reorganization.
    
    Furthermore, during this phase the token is lost and therefore no API
    level communication can take place. This will lead to timeouts of
    requests issued by the data model and subsequent retransmissions or
    false interpreation of a device failure.
    
    Closes #254

commit 6bc9a0c648f7c4dffaa0e5549d933dfe0bc43940
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Fri Dec 18 13:55:36 2009 +0100

    Michael Tross: Change dS485 protocol timings
    
    The following timeout changes in unix/ds485.cpp improve the stability.
    
    Closes #255

-----------------------------------------------------------------------

Changes:
diff --git a/unix/ds485.cpp b/unix/ds485.cpp
index 77e2a8f..990e46c 100644
--- a/unix/ds485.cpp
+++ b/unix/ds485.cpp
@@ -174,7 +174,7 @@ namespace dss {
   } // setRS485DeviceName
 
   DS485Frame* DS485Controller::getFrameFromWire() {
-    DS485Frame* result = m_FrameReader.getFrame(100);
+    DS485Frame* result = m_FrameReader.getFrame(200);
     if(result != NULL) {
       DS485CommandFrame* cmdFrame = dynamic_cast<DS485CommandFrame*>(result);
       if(cmdFrame != NULL) {
@@ -274,7 +274,7 @@ namespace dss {
     while(!m_Terminated) {
 
       if(m_State == csInitial) {
-        senseTimeMS = (rand() % 1000) + 100;
+        senseTimeMS = (rand() % 1000) + 2500;
         numberOfJoinPacketsToWait = -1;
         m_TokenCounter = 0;
         lastSentWasToken = false;
@@ -333,6 +333,11 @@ namespace dss {
         flush(std::cout);
       } else {
         DS485Header& header = frame->getHeader();
+
+        if (header.getSource() == m_StationID) {
+          continue;
+        }
+
         DS485CommandFrame* cmdFrame = dynamic_cast<DS485CommandFrame*>(frame.get());
         lastSentWasToken = false;
         missedFramesCounter = 0;
@@ -382,8 +387,7 @@ namespace dss {
         case csSlaveWaitingToJoin:
           {
             if(cmdFrame != NULL) {
-              if((cmdFrame->getCommand() == CommandSolicitSuccessorRequest) ||
-                 (cmdFrame->getCommand() == CommandSolicitSuccessorRequestLong)) {
+              if(cmdFrame->getCommand() == CommandSolicitSuccessorRequestLong) {
                 // if it's the first of it's kind, determine how many we've got to skip
                 if(numberOfJoinPacketsToWait == -1) {
                   if(cmdFrame->getCommand() == CommandSolicitSuccessorRequest) {
@@ -426,16 +430,17 @@ namespace dss {
               // check if our response has timed-out
               time_t now;
               time(&now);
-              if((now - responseSentAt) > 1) {
-                doChangeState(csSlaveWaitingToJoin);
-                std::cerr << "çççççççççç haven't received my address" << std::endl;
+              if((now - responseSentAt) > 5) {
+                doChangeState(csInitial);
+                Logger::getInstance()->log("DS485: startup timeout", lsError);
               }
             }
             if((m_StationID != 0x3F) && (m_NextStationID != 0xFF)) {
-              Logger::getInstance()->log("######### successfully joined the network", lsInfo);
+              Logger::getInstance()->log("DS485: joined network", lsInfo);
               token->getHeader().setDestination(m_NextStationID);
               token->getHeader().setSource(m_StationID);
               doChangeState(csSlaveWaitingForFirstToken);
+              time(&tokenReceivedAt);
             }
           }
           break;
@@ -460,7 +465,13 @@ namespace dss {
                 m_PendingFrames.erase(m_PendingFrames.begin());
               } else {
                 boost::shared_ptr<DS485Frame> ackFrame(m_FrameReader.getFrame(50));
+
                 DS485CommandFrame* cmdAckFrame = dynamic_cast<DS485CommandFrame*>(ackFrame.get());
+                if (cmdAckFrame->getHeader().getSource() == m_StationID) {
+                  ackFrame.reset( m_FrameReader.getFrame(50) );
+                }
+
+                cmdAckFrame = dynamic_cast<DS485CommandFrame*>(ackFrame.get());
                 if(cmdAckFrame != NULL) {
                   if(cmdAckFrame->getCommand() == CommandAck) {
                     m_PendingFrames.erase(m_PendingFrames.begin());
@@ -523,6 +534,10 @@ namespace dss {
                 std::cout << "a(req)";
               }
               keep = true;
+            } else if(cmdFrame->getCommand() == CommandSolicitSuccessorRequest) {
+              std::cout << "SSRS -> reset" << std::endl;
+              flush(std::cout);
+              doChangeState(csInitial);
             } else if(cmdFrame->getCommand() == CommandSetSuccessorAddressRequest) {
               if(header.getDestination() == m_StationID) {
                 handleSetSuccessor(cmdFrame);
@@ -540,14 +555,24 @@ namespace dss {
           }
           break;
         case csSlaveWaitingForFirstToken:
-          if(cmdFrame == NULL) {
-            if(header.getDestination() == m_StationID) {
-              putFrameOnWire(token.get(), false);
-              m_TokenCounter = 0;
-              doChangeState(csSlave);
-              time(&tokenReceivedAt);
-//              std::cout << ">";
-//              flush(std::cout);
+          {
+            if(cmdFrame == NULL) {
+              if(header.getDestination() == m_StationID) {
+                putFrameOnWire(token.get(), false);
+                m_TokenCounter = 0;
+                doChangeState(csSlave);
+                time(&tokenReceivedAt);
+                std::cout << "DS485: Got first TOKEN" << std::endl;
+                flush(std::cout);
+              }
+            }
+            // Handle timeout
+            time_t now;
+            time(&now);
+            if((now - tokenReceivedAt) > 15) {
+              std::cerr << "DS485: Wait for token timeout, restarting" << std::endl;
+              doChangeState(csInitial);
+              continue;
             }
           }
           break;


hooks/post-receive
-- 
digitalSTROM Server


More information about the dss-commits mailing list