Changeset b84e8b


Ignore:
Timestamp:
01/12/12 11:39:04 (4 months ago)
Author:
Stefan Persson <stefan.persson@…>
Branches:
('master', 'deebf2045e7119c339412580f37a1e653f7d5715')('controller-upgrade', '00f95d22e12d96ef089e0902ef62ae8ce841dc6f')
Children:
c527223bc420b18a6de5b3037befd935a288597f
Parents:
69059b935b81ae1ab0b06c99638a1b837619e05c
git-author:
Stefan Persson <stefan.persson@telldus.se>2012-01-12 11:39:04+01:00
git-committer:
Stefan Persson <stefan.persson@telldus.se>2012-01-12 11:39:04+01:00
Message:

Added TELLSTICK_ERROR_BROKEN_PIPE to distinguate between when communication with TellStick fails due to timeout or actual error.

Location:
telldus-core
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • telldus-core/client/Client.cpp

    rb0f092 rb84e8b  
    307307                        continue; //retry 
    308308                } 
    309                 readData = s.read(10000);  //TODO changed to 10000 from 5000, how much does this do...? 
     309                readData = s.read(8000);  //TODO changed to 10000 from 5000, how much does this do...? 
    310310                if(readData == L""){ 
    311311                        printf("Readdata nothing\n\r"); 
  • telldus-core/client/telldus-core.cpp

    r265daf rb84e8b  
    5757 * @def TELLSTICK_SUCCESS 
    5858 * Error code. Returned when the command succeeded. 
     59 * 
     60 * @def TELLSTICK_ERROR_BROKEN_PIPE 
     61 * Error code. Pipe broken during communication. 
    5962 * 
    6063 * @def TELLSTICK_ERROR_NOT_FOUND 
     
    488491 * @sa TELLSTICK_ERROR_UNKNOWN_RESPONSE 
    489492 * @sa TELLSTICK_ERROR_SYNTAX 
     493 * @sa TELLSTICK_ERROR_BROKEN_PIPE 
    490494 * @sa TELLSTICK_ERROR_UNKNOWN 
    491495 */ 
    492496char * WINAPI tdGetErrorString(int intErrorNo) { 
    493         const int numResponses = 9; 
     497        const int numResponses = 10; 
    494498        const char *responses[numResponses] = { 
    495499                "Success", 
     
    501505                "Could not connect to the Telldus Service", 
    502506                "Received an unknown response", 
    503                 "Syntax error" 
     507                "Syntax error", 
     508                "Broken pipe" 
    504509        }; 
    505510        std::string strReturn; 
  • telldus-core/client/telldus-core.h

    r554601 rb84e8b  
    117117#define TELLSTICK_ERROR_UNKNOWN_RESPONSE -7 
    118118#define TELLSTICK_ERROR_SYNTAX -8 
     119#define TELLSTICK_ERROR_BROKEN_PIPE -9 
    119120#define TELLSTICK_ERROR_UNKNOWN -99 
    120121 
  • telldus-core/service/ClientCommunicationHandler.cpp

    rd7cce5 rb84e8b  
    22#include "Message.h" 
    33#include "Strings.h" 
    4 #include "Log.h" //Debug 
    54 
    65#include <stdlib.h> 
  • telldus-core/service/ControllerManager.cpp

    r8d22ef rb84e8b  
    141141        for(std::list<TellStick *>::iterator it = tellStickControllers.begin(); it != tellStickControllers.end(); ++it) { 
    142142                int success = (*it)->send(noop); 
    143                 if(success == TELLSTICK_ERROR_COMMUNICATION){ 
     143                if(success == TELLSTICK_ERROR_BROKEN_PIPE){ 
    144144                        Log::warning("TellStick query: Error in communication with TellStick, resetting USB"); 
    145145                        resetController(*it); 
    146146                } 
    147                 if(success == TELLSTICK_ERROR_COMMUNICATION || success == TELLSTICK_ERROR_NOT_FOUND){ 
     147                if(success == TELLSTICK_ERROR_BROKEN_PIPE || success == TELLSTICK_ERROR_NOT_FOUND){ 
    148148                        reloadControllers = true; 
    149149                } 
  • telldus-core/service/DeviceManager.cpp

    r8d22ef rb84e8b  
    442442                if(controller){ 
    443443                        retval = device->doAction(action, data, controller); 
    444                         if(retval == TELLSTICK_ERROR_COMMUNICATION){ 
     444                        if(retval == TELLSTICK_ERROR_BROKEN_PIPE){ 
    445445                                Log::warning("Error in communication with TellStick when executing action. Resetting USB"); 
    446446                                d->controllerManager->resetController(controller); 
    447447                        } 
    448                         if(retval == TELLSTICK_ERROR_COMMUNICATION || retval == TELLSTICK_ERROR_NOT_FOUND){ 
     448                        if(retval == TELLSTICK_ERROR_BROKEN_PIPE || retval == TELLSTICK_ERROR_NOT_FOUND){ 
    449449                                Log::warning("Rescanning USB ports"); 
    450450                                d->controllerManager->loadControllers(); 
     
    752752        if(controller){ 
    753753                retval = controller->send(TelldusCore::wideToString(command)); 
    754                 if(retval == TELLSTICK_ERROR_COMMUNICATION){ 
     754                if(retval == TELLSTICK_ERROR_BROKEN_PIPE){ 
    755755                        d->controllerManager->resetController(controller); 
    756756                } 
    757                 if(retval == TELLSTICK_ERROR_COMMUNICATION || retval == TELLSTICK_ERROR_NOT_FOUND){ 
     757                if(retval == TELLSTICK_ERROR_BROKEN_PIPE || retval == TELLSTICK_ERROR_NOT_FOUND){ 
    758758                        d->controllerManager->loadControllers(); 
    759759                        controller = d->controllerManager->getBestControllerById(-1); 
  • telldus-core/service/TellStick_libftdi.cpp

    r69059b rb84e8b  
    218218        delete[] tempMessage; 
    219219        Log::notice("Message: %s", strMessage.c_str()); 
     220        Log::notice("FWVersion: %d", firmwareVersion()); 
     221        Log::notice("Pid: %X", pid()); 
     222 
     223        if(!c){ 
     224                Log::debug("Broken pipe on send"); 
     225                return TELLSTICK_ERROR_BROKEN_PIPE; 
     226        } 
     227 
    220228        if(d->ignoreControllerConfirmation || (strMessage == "N+" && ((pid() == 0x0C31 && firmwareVersion() < 5) || (pid() == 0x0C30 && firmwareVersion() < 6)))){ 
    221229                //these firmware versions doesn't implement ack to noop, just check that the noop can be sent correctly 
    222                 Log::notice("Too old firmware, accepting this"); 
    223                 if(c){ 
    224                         Log::notice("Success"); 
    225                         return TELLSTICK_SUCCESS; 
    226                 } 
    227                 else{ 
    228                         Log::notice("Fail"); 
    229                         return TELLSTICK_ERROR_COMMUNICATION; 
    230                 } 
     230                Log::notice("Too old firmware, accepting this, just return success"); 
     231                return TELLSTICK_SUCCESS; 
    231232        } 
    232233        Log::warning("Continuing"); 
     
    234235        int retrycnt = 250; 
    235236        unsigned char in; 
    236         while(c && --retrycnt) { 
     237        while(--retrycnt) { 
    237238                ret = ftdi_read_data( &d->ftHandle, &in, 1); 
    238239                if (ret > 0) { 
    239                         Log::notice("Returned %c", in); 
     240                        Log::warning("%c", in); 
    240241                        if (in == '\n') { 
    241                                 Log::notice("BREAK"); 
     242                                Log::warning("Received an end"); 
    242243                                break; 
    243244                        } 
     
    245246                        usleep(100); 
    246247                } else { //Error 
    247                         c = false; 
    248                 } 
    249         } 
     248                        Log::debug("Broken pipe on read"); 
     249                        return TELLSTICK_ERROR_BROKEN_PIPE; 
     250                } 
     251        } 
     252        Log::warning("Retry ready"); 
    250253        if (!retrycnt) { 
    251                 c = false; 
    252         } 
    253         if (!c) { 
     254                Log::warning("Error in communication, retrycount ended"); 
    254255                return TELLSTICK_ERROR_COMMUNICATION; 
    255256        } 
     257        Log::warning("Success"); 
    256258        return TELLSTICK_SUCCESS; 
    257259} 
  • telldus-core/service/TelldusMain.cpp

    r8d22ef rb84e8b  
    4444        EventRef janitor = d->eventHandler.addEvent(); //Used for regular cleanups 
    4545        Timer supervisor(janitor); //Tells the janitor to go back to work 
    46         supervisor.setInterval(10); //TODO Once every minute 
     46        supervisor.setInterval(60); //Once every minute 
    4747        supervisor.start(); 
    4848 
Note: See TracChangeset for help on using the changeset viewer.