Changeset 8d22ef


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

Added wait for ack on noop-command

Location:
telldus-core/service
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • telldus-core/service/ControllerManager.cpp

    r673daf r8d22ef  
    9393 
    9494        std::list<TellStickDescriptor>::iterator it = list.begin(); 
    95         Log::notice("Before for-loop"); 
    9695        for(; it != list.end(); ++it) { 
    97                 Log::notice("Something in the loop"); 
    9896                //Most backend only report non-opened devices. 
    9997                //If they don't make sure we don't open them twice 
     
    10199                ControllerMap::const_iterator cit = d->controllers.begin(); 
    102100                for(; cit != d->controllers.end(); ++cit) { 
    103                         Log::notice("Something in the second loop"); 
    104101                        TellStick *tellstick = reinterpret_cast<TellStick*>(cit->second); 
    105102                        if (!tellstick) { 
    106                                 Log::notice("No tellstick"); 
    107103                                continue; 
    108104                        } 
    109105                        if (tellstick->isSameAsDescriptor(*it)) { 
    110106                                found = true; 
    111                                 Log::notice("FOUND"); 
    112107                                break; 
    113108                        } 
     
    119114                int controllerId = d->lastControllerId-1; 
    120115                TellStick *controller = new TellStick(controllerId, d->event, *it); 
    121                 Log::notice("Is it open?"); 
    122116                if (!controller->isOpen()) { 
    123                         Log::notice("Yes it was"); 
    124117                        delete controller; 
    125118                        continue; 
     
    137130                TelldusCore::MutexLocker locker(&d->mutex); 
    138131                for(ControllerMap::iterator it = d->controllers.begin(); it != d->controllers.end(); ++it) { 
    139                         Log::notice("found a controller"); 
    140132                        TellStick *tellstick = reinterpret_cast<TellStick*>(it->second); 
    141133                        if (tellstick) { 
    142                                 Log::notice("found a tellstick"); 
    143134                                tellStickControllers.push_back(tellstick); 
    144135                        } 
     
    147138 
    148139        bool reloadControllers = false; 
    149         std::string noop = "noop"; 
     140        std::string noop = "N+"; 
    150141        for(std::list<TellStick *>::iterator it = tellStickControllers.begin(); it != tellStickControllers.end(); ++it) { 
    151142                int success = (*it)->send(noop); 
     
    153144                        Log::warning("TellStick query: Error in communication with TellStick, resetting USB"); 
    154145                        resetController(*it); 
    155                         Log::notice("has reset"); 
    156146                } 
    157147                if(success == TELLSTICK_ERROR_COMMUNICATION || success == TELLSTICK_ERROR_NOT_FOUND){ 
    158148                        reloadControllers = true; 
    159                         Log::notice("Set reload"); 
    160149                } 
    161150        } 
     
    163152        if(!tellStickControllers.size() || reloadControllers){ 
    164153                //no tellstick at all found, or controller was reset 
    165                 Log::warning("TellStick query: Rescanning USB ports"); 
     154                Log::debug("TellStick query: Rescanning USB ports");  //only log as debug, since this will happen all the time if no TellStick is connected 
    166155                loadControllers(); 
    167156        } 
     
    173162                return true; //not tellstick, nothing to reset at the moment, just return true 
    174163        } 
    175         Log::notice("resettingController"); 
    176         int success = controller->reset(); 
    177         Log::notice("Remove device"); 
     164        int success = tellstick->reset(); 
    178165        deviceInsertedOrRemoved(tellstick->vid(), tellstick->pid(), tellstick->serial(), false); //remove from list and delete 
    179         Log::notice("Device removed"); 
    180166        return success; 
    181167} 
  • telldus-core/service/DeviceManager.cpp

    rdfae48 r8d22ef  
    66#include "Strings.h" 
    77#include "Message.h" 
    8  
    9 #include "common.h" //TODO remove? 
    10 #include "Log.h" //TODO remove? 
     8#include "Log.h" 
    119 
    1210#include <map> 
     
    434432        } 
    435433        else{ 
    436                 Log::notice("Getting a controller..."); 
    437434                Controller *controller = d->controllerManager->getBestControllerById(device->getPreferredControllerId()); 
    438                 Log::notice("Doing action..."); 
    439435                if(!controller){ 
    440                         Log::warning("No controller found, rescanning USB ports"); 
     436                        Log::warning("Trying to execute action, but no controller found. Rescanning USB ports"); 
    441437                        //no controller found, scan for one, and retry once 
    442438                        d->controllerManager->loadControllers(); 
     
    445441 
    446442                if(controller){ 
    447                         Log::notice("But now, a controller!"); 
    448443                        retval = device->doAction(action, data, controller); 
    449                         Log::notice("Retval received, %d.", retval); 
    450444                        if(retval == TELLSTICK_ERROR_COMMUNICATION){ 
    451                                 Log::warning("Error in communication with TellStick, resetting USB"); 
     445                                Log::warning("Error in communication with TellStick when executing action. Resetting USB"); 
    452446                                d->controllerManager->resetController(controller); 
    453                                 Log::notice("Controller reset"); 
    454447                        } 
    455448                        if(retval == TELLSTICK_ERROR_COMMUNICATION || retval == TELLSTICK_ERROR_NOT_FOUND){ 
    456449                                Log::warning("Rescanning USB ports"); 
    457450                                d->controllerManager->loadControllers(); 
    458                                 Log::notice("Loaded, get one"); 
    459451                                controller = d->controllerManager->getBestControllerById(device->getPreferredControllerId()); 
    460452                                if(!controller){ 
     
    462454                                        return TELLSTICK_ERROR_NOT_FOUND; 
    463455                                } 
    464                                 Log::notice("Got a new, do action"); 
    465456                                retval = device->doAction(action, data, controller); //retry one more time 
    466                                 Log::notice("Did action"); 
    467457                        } 
    468458                } else { 
  • telldus-core/service/TellStick_libftdi.cpp

    r673daf r8d22ef  
    146146 
    147147int TellStick::reset(){ 
    148         Log::notice("Resetting one"); 
    149148        int success = ftdi_usb_reset( &d->ftHandle ); 
    150         Log::notice("Has reset one"); 
    151149        if(success < 0){ 
    152150                return TELLSTICK_ERROR_UNKNOWN; //-1 = FTDI reset failed, -2 = USB device unavailable 
     
    211209                c = false; 
    212210        } else if(ret != strMessage.length()) { 
    213                 fprintf(stderr, "weird send length? retval %i instead of %d\n", 
    214                 ret, (int)strMessage.length()); 
     211                Log::debug("Weird send length? retval %i instead of %d\n", ret, (int)strMessage.length()); 
    215212        } 
    216213 
    217214        delete[] tempMessage; 
    218         if(strMessage == "noop"){ 
     215        Log::notice("Message: %s", strMessage.c_str()); 
     216        if(strMessage == "N+" && ((pid() == 0x0C31 && firmwareVersion() < 5) || (pid() == 0x0C30 && firmwareVersion() < 6))){ 
     217                //these firmware versions doesn't implement ack to noop, just check that the noop can be sent correctly 
     218                Log::notice("Too old firmware, accepting this"); 
    219219                if(c){ 
    220220                        return TELLSTICK_SUCCESS; 
     
    224224                } 
    225225        } 
     226        Log::warning("Continuing"); 
    226227 
    227228        int retrycnt = 500; 
     
    301302        ftdi_init(&ftdic); 
    302303 
    303         Log::notice("Trying to find Duo"); 
    304304        int ret = ftdi_usb_find_all(&ftdic, &devlist, vid, pid); 
    305305        if (ret > 0) { 
    306                 Log::notice("Curdev > 0"); 
    307306                for (curdev = devlist; curdev != NULL; curdev = curdev->next) { 
    308                         Log::notice("Something in the loop"); 
    309307                        ret = ftdi_usb_get_strings(&ftdic, curdev->dev, NULL, 0, NULL, 0, serialBuffer, 10); 
    310                         Log::notice("Ret: %d",ret); 
    311                         //blir -9 efter felen, "get serial number failed", även lsusb -v ger annat svar än innan...? 
    312308                        if (ret != 0) { 
    313309                                continue; 
  • telldus-core/service/TelldusMain.cpp

    r673daf r8d22ef  
    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); //Every 5 minutes TODO how often? 60*5 
     46        supervisor.setInterval(10); //TODO Once every minute 
    4747        supervisor.start(); 
    4848 
Note: See TracChangeset for help on using the changeset viewer.