void DevQue::transmit(const std::string& data, const mac_type& mac)
throw (std::runtime_error, std::logic_error)
{
+#ifdef DEBUG_TRACE
+ std::cout << "DevQue[" << que_id << "]::transmit()\n";
+#endif
if (data.size() > mtu)
throw std::logic_error("Tamaño de datos mayor al MTU");
Frame* f = (Frame*) malloc(sizeof(Frame) + mtu);
throw std::runtime_error("No se puede reservar memoria");
f->mac = mac;
f->size = data.size();
- memcpy(f->frame, data.c_str(), data.size());
+ memcpy(f->frame, data.data(), data.size());
int res = msgsnd(que_id, f, mtu + sizeof(size_t), 0);
-#ifdef DEBUG2
- std::cout << "DevQue::transmit(msgtype/mac = " << f->mac << ", size = "
- << f->size << ")\n";
+#ifdef DEBUG_QUE
+ std::cout << "DevQue[" << que_id << "]::transmit(msgtype/mac = "
+ << f->mac << ", size = " << f->size << ")\n";
#endif
free(f);
if (res == -1)
std::string DevQue::receive() throw (std::runtime_error)
{
+#ifdef DEBUG_TRACE
+ std::cout << "DevQue[" << que_id << "]::receive()\n";
+#endif
return receive(mac);
}
std::string DevQue::receive(mac_type& mac) throw (std::runtime_error)
{
+#ifdef DEBUG_TRACE
+ std::cout << "DevQue[" << que_id << "]::receive(mac)\n";
+#endif
Frame* f = (Frame*) malloc(sizeof(Frame) + mtu);
if (!f)
throw std::runtime_error("No se puede reservar memoria");
if (mac == 0)
mac = f->mac;
free(f);
-#ifdef DEBUG2
- std::cout << "DevQue::receive(msgtype/mac = " << mac << ", size = "
- << s.size() << ")\n";
+#ifdef DEBUG_QUE
+ std::cout << "DevQue[" << que_id << "]::receive(msgtype/mac = "
+ << mac << ", size = " << s.size() << ")\n";
#endif
return s;
}