X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fcontrol.cpp;h=fa1117ccd0fa319dd6c15bf5c735092e8fe27ada;hb=212bc6eb3ab2dbad39725984ac715c64f8de29ff;hp=4f63cc20be086e90e4c56c7e2d768665444a2044;hpb=dcc8378d809e5d2e53db77234559b0556195e693;p=r2c2.git diff --git a/source/libmarklin/control.cpp b/source/libmarklin/control.cpp index 4f63cc2..fa1117c 100644 --- a/source/libmarklin/control.cpp +++ b/source/libmarklin/control.cpp @@ -1,15 +1,15 @@ /* $Id$ This file is part of the MSP Märklin suite -Copyright © 2007-2008 Mikkosoft Productions, Mikko Rasa +Copyright © 2007-2009 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ #include #include #include -#include #include +#include #include #include #include "command.h" @@ -72,7 +72,7 @@ void Control::open(const string &dev) pollfd pfd = { serial_fd, POLLIN, 0 }; if(poll(&pfd, 1, 500)>0) { - cout<<"IB detected at "<=0) queue.front().send(serial_fd); else + { + Reply reply = Reply::simulate(queue.front().get_command()); + queue.front().signal_done.emit(reply); queue.erase(queue.begin()); + } } } @@ -240,7 +244,7 @@ void Control::event_query_done(const Reply &reply) command(CMD_EVENT_TURNOUT).signal_done.connect(sigc::mem_fun(this, &Control::turnout_event_done)); if(data[0]&0x04) command(CMD_EVENT_SENSOR).signal_done.connect(sigc::mem_fun(this, &Control::sensor_event_done)); - if(data[1]&0x40) + if((data[0]&0x80) && (data[1]&0x40)) command(CMD_STATUS).signal_done.connect(sigc::mem_fun(this, &Control::status_done)); } @@ -252,7 +256,7 @@ void Control::turnout_event_done(const Reply &reply) { unsigned addr = (data[i*2+1])+((data[i*2+2]&7)<<8); bool status = !(data[i*2+2]&0x80); - cout<<"Turnout "<>(7-j%8))&1); - cout<<'\n'; + IO::print("S88 module %d, status %08b%08b\n", module, data[1], data[2]); for(unsigned j=0; j<16; ++j) signal_sensor_event.emit(module*16+j-15, (data[i+1+j/8]>>(7-j%8))&1);