Changeset c52722


Ignore:
Timestamp:
01/12/12 14:17:24 (4 months ago)
Author:
Stefan Persson <stefan.persson@…>
Branches:
('master', 'deebf2045e7119c339412580f37a1e653f7d5715')('controller-upgrade', '00f95d22e12d96ef089e0902ef62ae8ce841dc6f')
Children:
3ce58f019fbe42e77592b30166a1f44a732eeee5
Parents:
b84e8b3806d9db62cfda5035e274ef6fe0b9f817
git-author:
Stefan Persson <stefan.persson@telldus.se>2012-01-12 14:17:24+01:00
git-committer:
Stefan Persson <stefan.persson@telldus.se>2012-01-12 14:17:24+01:00
Message:

Made use of TELLSTICK_ERROR_BROKEN_PIPE in windows too

File:
1 edited

Legend:

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

    r406874 rc52722  
    1111// 
    1212#include "TellStick.h" 
     13#include "common.h" 
    1314#include "Mutex.h" 
    1415#include "Settings.h" 
     
    211212                return TELLSTICK_ERROR_NOT_FOUND; 
    212213        } 
    213         bool c = true; 
    214  
     214         
    215215        //This lock does two things 
    216216        // 1 Prevents two calls from different threads to this function 
     
    231231        free(tempMessage); 
    232232         
    233         if(d->ignoreControllerConfirmation || (strMessage == "N+" && ((pid() == 0x0C31 && firmwareVersion() < 5) || (pid() == 0x0C30 && firmwareVersion() < 6)))){ 
     233        if(ftStatus != FT_OK){ 
     234                Log::debug("Broken pipe on send"); 
     235                return TELLSTICK_ERROR_BROKEN_PIPE; 
     236        } 
     237 
     238        if(strMessage.compare("N+") == 0 && ((pid() == 0x0C31 && firmwareVersion() < 5) || (pid() == 0x0C30 && firmwareVersion() < 6))){ 
    234239                //these firmware versions doesn't implement ack to noop, just check that the noop can be sent correctly 
    235                 if(c){ 
    236                         return TELLSTICK_SUCCESS; 
    237                 } 
    238                 else{ 
    239                         return TELLSTICK_ERROR_COMMUNICATION; 
    240                 } 
    241         } 
    242  
    243         while(c) { 
     240                return TELLSTICK_SUCCESS; 
     241        } 
     242        if(d->ignoreControllerConfirmation){ 
     243                //wait for TellStick to finish its air-sending 
     244                msleep(1000); 
     245                return TELLSTICK_SUCCESS; 
     246        } 
     247 
     248        while(1) { 
    244249                ftStatus = FT_Read(d->ftHandle,&in,1,&bytesRead); 
    245250                if (ftStatus == FT_OK) { 
    246251                        if (bytesRead == 1) { 
    247252                                if (in == '\n') { 
    248                                         break; 
     253                                        return TELLSTICK_SUCCESS; 
     254                                } else { 
     255                                        continue; 
    249256                                } 
    250257                        } else { //Timeout 
    251                                 c = false; 
     258                                return TELLSTICK_ERROR_COMMUNICATION; 
    252259                        } 
    253260                } else { //Error 
    254                         c = false; 
    255                 } 
    256         } 
    257  
    258         if (!c) { 
    259                 return TELLSTICK_ERROR_COMMUNICATION; 
    260         } 
    261         return TELLSTICK_SUCCESS; 
     261                        Log::debug("Broken pipe on read"); 
     262                        return TELLSTICK_ERROR_BROKEN_PIPE; 
     263                } 
     264        } 
    262265} 
    263266 
Note: See TracChangeset for help on using the changeset viewer.