]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/control.cpp
Change terminology to better distinguish routes on the layout from paths across track...
[r2c2.git] / source / libmarklin / control.cpp
index 6f7ef74dbf30bc18cd83bd111e994ef7e606c619..4f63cc20be086e90e4c56c7e2d768665444a2044 100644 (file)
@@ -36,7 +36,8 @@ Control::~Control()
                delete i->second;
        for(map<unsigned, Locomotive *>::iterator i=locomotives.begin(); i!=locomotives.end(); ++i)
                delete i->second;
-       close(serial_fd);
+       if(serial_fd>=0)
+               close(serial_fd);
 }
 
 void Control::open(const string &dev)
@@ -212,7 +213,10 @@ void Control::tick()
                if(debug)
                        cout<<"W: "<<queue.front()<<'\n';
 
-               queue.front().send(serial_fd);
+               if(serial_fd>=0)
+                       queue.front().send(serial_fd);
+               else
+                       queue.erase(queue.begin());
        }
 }