Subversion Repositories HomeAutomation

Rev

Rev 1915 | Rev 1917 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1915 Rev 1916
Line 43... Line 43...
43
    PACKET_START = 253,
43
    PACKET_START = 253,
44
    PACKET_END   = 250,
44
    PACKET_END   = 250,
45
    PACKET_PING  = 251
45
    PACKET_PING  = 251
46
};
46
};
47
   
47
   
48
Network::Network(std::string address): broker::Subscriber(false), LOG("can::Network"), buffer_(2048)
48
Network::Network(std::string address): broker::Subscriber(false), buffer_(2048), LOG("can::Network")
49
{
49
{
50
    this->address_ = address;
50
    this->address_ = address;
51
    this->client_id_ = 0;
51
    this->client_id_ = 0;
52
       
52
       
53
    // Examples of address
53
    // Examples of address
Line 312... Line 312...
312
        std::string direction_name = "";
312
        std::string direction_name = "";
313
        std::string module_name = "";
313
        std::string module_name = "";
314
        unsigned int id = 0;
314
        unsigned int id = 0;
315
        std::string command_name = "";
315
        std::string command_name = "";
316
       
316
       
317
    std::string PKTstring = "PKT "+atom::common::ToHex8bit((unsigned int)this->buffer_[3])+atom::common::ToHex8bit((unsigned int)this->buffer_[2])+atom::common::ToHex8bit((unsigned int)this->buffer_[1])+atom::common::ToHex8bit((unsigned int)this->buffer_[0])+ " "+atom::common::ToHex4bit((unsigned int)this->buffer_[4])+ " "+atom::common::ToHex4bit((unsigned int)this->buffer_[5]);
317
    std::string PKTstring = "PKT " +
-
 
318
                atom::common::ToHex8bit((unsigned int)this->buffer_[3]) +
-
 
319
                atom::common::ToHex8bit((unsigned int)this->buffer_[2]) +
-
 
320
                atom::common::ToHex8bit((unsigned int)this->buffer_[1]) +
-
 
321
                atom::common::ToHex8bit((unsigned int)this->buffer_[0]) +
-
 
322
                " " +
-
 
323
                atom::common::ToHex4bit((unsigned int)this->buffer_[4]) +
-
 
324
                " " +
-
 
325
                atom::common::ToHex4bit((unsigned int)this->buffer_[5]);
-
 
326
   
318
    for (id=7;id< 7+(unsigned int)this->buffer_[6] ;id++) {
327
    for (unsigned int index = 7; index < 7 + (unsigned int)this->buffer_[6]; index++)
-
 
328
    {
319
        PKTstring += " " + atom::common::ToHex8bit((unsigned int)this->buffer_[id]) ;
329
        PKTstring += " " + atom::common::ToHex8bit((unsigned int)this->buffer_[index]) ;
320
    }
330
    }
-
 
331
   
321
    PKTstring += "\n";
332
    PKTstring += "\n";
-
 
333
   
322
    //LOG.Info(PKTstring);
334
    //LOG.Info(PKTstring);
-
 
335
   
323
    std::string* payload_str = new std::string(PKTstring);
336
    std::string* payload_str = new std::string(PKTstring);
324
    broker::Manager::Instance()->Post(broker::Message::Pointer(new broker::Message(broker::Message::CAN_RAW_MESSAGE, broker::Message::PayloadPointer(payload_str), this)));
337
    broker::Manager::Instance()->Post(broker::Message::Pointer(new broker::Message(broker::Message::CAN_RAW_MESSAGE, broker::Message::PayloadPointer(payload_str), this)));
325
    id = 0;
338
 
326
   
339
   
327
        unsigned int class_id = (this->buffer_[3] >> 1) & 0x0F;
340
        unsigned int class_id = (this->buffer_[3] >> 1) & 0x0F;
328
        //LOG.Debug("class_id=" + boost::lexical_cast<std::string>(class_id));
341
        //LOG.Debug("class_id=" + boost::lexical_cast<std::string>(class_id));
329
        class_name = Protocol::Instance()->LookupClassName(class_id);
342
        class_name = Protocol::Instance()->LookupClassName(class_id);
330
       
343