]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/locomotive.cpp
Support dual-address locomotives with extra functions on the second address
[r2c2.git] / source / libmarklin / locomotive.cpp
index 2df46a0d7fae67429c6ddea6be63da3e81c9f6eb..5fe5ca5f863d07ca489cdea2bae773eb46ba9d8e 100644 (file)
@@ -11,6 +11,7 @@ Distributed under the GPL
 #include "constants.h"
 #include "control.h"
 #include "locomotive.h"
+#include "locotype.h"
 #include "reply.h"
 
 using namespace std;
@@ -105,6 +106,18 @@ void Locomotive::send_command(bool setf)
                                data[3] |= (1<<i);
        }
        control.command(CMD_LOK, data, 4);
+
+       if(setf && type.get_max_function()>4)
+       {
+               if(!++data[0])
+                       ++data[1];
+               data[2] = 0;
+               data[3] = 0xA0;
+               for(unsigned i=0; i<4; ++i)
+                       if((funcs>>i)&32)
+                               data[3] |= (1<<i);
+               control.command(CMD_LOK, data, 4);
+       }
 }
 
 void Locomotive::status_reply(const Reply &reply)