Ticket #268 (reopened defect)

Opened 8 years ago

Last modified 7 years ago

Problem with tdtool extended command

Reported by: karlox loma <karloxloma@…> Owned by:
Priority: major Milestone:
Component: telldus-core Version: 2.1.1
Keywords: Cc:
Blocked By: Blocking:
Platform: Linux Sensitive: no
Verified by Telldus: no


Whenever a value above "\x7F" (!!!1127 in Dec) is send in a raw command (In extended command confirmed, but I guess also in the basic command) the final packet is malformed.

signed versus unsigned data storage?

Change History

comment:1 Changed 8 years ago by micke prag <micke.prag@…>

  • Status changed from new to closed
  • Resolution set to worksforme

Could you please provide a complete example?

comment:2 Changed 7 years ago by sebastian strand <sebstrand@…>

  • Status changed from closed to reopened
  • Resolution worksforme deleted

I'm running into the same issue. I cannot send raw commands to my Nexa devices using either Python (through ctypes) or tdtool. I am using a Tellstick Duo on 64-bit Linux.


echo -ne '\x54\x7f\xff\x18\x1\x84\x9a\x8a\x8a\x88\xa8\xaa\x8a\x8a\x8a\x8a\x88\xaa\x8a\x88\xa8\xa8\xa8\xaa\x88\xa8\xa8\xaa\x88\xaa\x88\xaa\x8a\x88\xaa\x8a\x8a\x8a\x8a\x2b' | tdtool --raw -

This command should turn on an arctech / Nexa selflearning device with house 6332138 and unit 1 but does nothing, or rather the Duo sends something but it has no effect. I have verified that those are in fact the correct bytes to send. I added some debug code and found that all character codes in the raw command string which are greater than 127 are converted to two bytes before being sent which breaks the command. I was able to make it work with this patch:

--- a/telldus-core/service/DeviceManager.cpp
+++ b/telldus-core/service/DeviceManager.cpp
@@ -757,7 +757,12 @@ int DeviceManager::sendRawCommand(const std::wstring &command, int reserved) {
        int retval = TELLSTICK_ERROR_UNKNOWN;
        if(controller) {
-               retval = controller->send(TelldusCore::wideToString(command));
+               char * charCommand = new char[command.length()+1];
+                for(int i = 0; i<command.length(); ++i) {
+                       charCommand[i] = (char)( command[i] & 0xff );
+                }
+               retval = controller->send(charCommand);
                if(retval == TELLSTICK_ERROR_BROKEN_PIPE) {
@@ -767,7 +772,7 @@ int DeviceManager::sendRawCommand(const std::wstring &command, int reserved) {
                        if(!controller) {
                                return TELLSTICK_ERROR_NOT_FOUND;
-                       retval = controller->send(TelldusCore::wideToString(command));  // retry one more time
+                       retval = controller->send(charCommand);  // retry one more time
                return retval;
        } else {

Note that I haven't checked if this breaks anything else, but it does let me send raw commands using Python and tdtool.

Note: See TracTickets for help on using tickets.