Revision: 7073 http://playerstage.svn.sourceforge.net/playerstage/?rev=7073&view=rev Author: thjc Date: 2008-10-07 10:19:43 +0000 (Tue, 07 Oct 2008)
Log Message: ----------- Merging changes from 2-1 to trunk: 6975 P2-1 Updated Serial Stream to use file watcher 6979 P2-1 cleaning up some debug messages that are too verbose 6980 P2-1 added socket header for missing defs on some platofrms 6981 P2-1 disabled very verbose debug messages in passthrough, dont think you would ever need it this verbose except while debugging passthrough (when they could be compiled back in) Modified Paths: -------------- code/player/trunk/server/drivers/opaque/serialstream.cc code/player/trunk/server/drivers/opaque/tcpstream.cc code/player/trunk/server/drivers/shell/passthrough.cc Modified: code/player/trunk/server/drivers/opaque/serialstream.cc =================================================================== --- code/player/trunk/server/drivers/opaque/serialstream.cc 2008-10-07 01:22:15 UTC (rev 7072) +++ code/player/trunk/server/drivers/opaque/serialstream.cc 2008-10-07 10:19:43 UTC (rev 7073) @@ -324,7 +324,6 @@ //else if it is a opaque data message then I want to flush the current serial port and write to whatever is connected to the serial port else if (Message::MatchMessage (hdr, PLAYER_MSGTYPE_CMD, PLAYER_OPAQUE_CMD_DATA, this->device_addr)) { - PLAYER_MSG0(2, "Command message received"); player_opaque_data_t * recv = reinterpret_cast<player_opaque_data_t * > (data); // Make sure both input and output queues are empty tcflush(opaque_fd, TCIOFLUSH); @@ -365,7 +364,7 @@ for(;;) { // test if we are supposed to cancel - pthread_testcancel(); + Wait(1); // Process incoming messages. SerialStream::ProcessMessage() is // called on each message. @@ -373,9 +372,6 @@ // Reads the data from the serial port and then publishes it ReadData(); - - // Sleep (you might, for example, block on a read() instead) - usleep(100000); } } @@ -406,6 +402,8 @@ usleep(1000); tcflush(opaque_fd, TCIFLUSH); + AddFileWatch(opaque_fd); + return 0; } @@ -498,6 +496,8 @@ // int SerialStream::CloseTerm() { + RemoveFileWatch(opaque_fd); + ::close(this->opaque_fd); return 0; } Modified: code/player/trunk/server/drivers/opaque/tcpstream.cc =================================================================== --- code/player/trunk/server/drivers/opaque/tcpstream.cc 2008-10-07 01:22:15 UTC (rev 7072) +++ code/player/trunk/server/drivers/opaque/tcpstream.cc 2008-10-07 10:19:43 UTC (rev 7073) @@ -103,6 +103,7 @@ #include <string.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/socket.h> #include <termios.h> #include <unistd.h> #include <sys/ioctl.h> Modified: code/player/trunk/server/drivers/shell/passthrough.cc =================================================================== --- code/player/trunk/server/drivers/shell/passthrough.cc 2008-10-07 01:22:15 UTC (rev 7072) +++ code/player/trunk/server/drivers/shell/passthrough.cc 2008-10-07 10:19:43 UTC (rev 7073) @@ -124,7 +124,7 @@ int ConnectRemote(); int DisconnectRemote(); - + virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr * hdr, void * data); private: @@ -136,16 +136,16 @@ player_devaddr_t srcAddr; //the device that this server connects to to get data Device *srcDevice; - + // properties StringProperty RemoteHost; IntProperty RemotePort; IntProperty RemoteIndex; - + IntProperty Connect; int Connected; - + }; Driver* @@ -206,7 +206,7 @@ int ret = ConnectRemote(); if (ret) return ret; - + } StartThread(); @@ -222,7 +222,7 @@ StopThread(); DisconnectRemote(); - + PLAYER_MSG0(1,"PassThrough driver has been shutdown"); return(0); @@ -232,7 +232,7 @@ { if (Connected) return 0; - + if (RemoteHost.GetValue()[0] != '\0') { PLAYER_MSG1(3,"Overriding remote hostname to %s", RemoteHost.GetValue()); @@ -275,7 +275,7 @@ return 0; //Our clients disconnected, so let's disconnect from our SRC interface srcDevice->Unsubscribe(this->InQueue); - + Connected = 0; return 0; } @@ -289,19 +289,19 @@ bool inspected(false); // let our properties through - if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, PLAYER_SET_STRPROP_REQ)) + if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, PLAYER_SET_STRPROP_REQ)) { player_strprop_req_t req = *reinterpret_cast<player_strprop_req_t*> (data); - if (strcmp("remote_host", req.key) == 0) + if (strcmp("remote_host", req.key) == 0) return -1; } - - if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, PLAYER_SET_INTPROP_REQ)) + + if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, PLAYER_SET_INTPROP_REQ)) { player_intprop_req_t req = *reinterpret_cast<player_intprop_req_t*> (data); - if (strcmp("remote_port", req.key) == 0) + if (strcmp("remote_port", req.key) == 0) return -1; - if (strcmp("remote_index", req.key) == 0) + if (strcmp("remote_index", req.key) == 0) return -1; if (strcmp("connect", req.key) == 0) { @@ -318,11 +318,11 @@ DisconnectRemote(); ConnectRemote(); } - + return -1; } } - + // silence warning etc while we are not connected if (!Connected) { @@ -332,8 +332,8 @@ } return 0; } - + PLAYER_MSG0(9,"PassThrough::ProcessMessage: Received a packet!"); if (Device::MatchDeviceAddress(hdr->addr,srcAddr) && @@ -342,7 +342,7 @@ (hdr->type == PLAYER_MSGTYPE_SYNCH) || (hdr->type == PLAYER_MSGTYPE_RESP_NACK))) { - PLAYER_MSG7(8,"PassThrough: Forwarding SRC->DST Interface code=%d %d:%d:%d -> %d:%d:%d",hdr->addr.interf, hdr->addr.host,hdr->addr.robot, hdr->addr.index, dstAddr.host, dstAddr.robot, dstAddr.index); + //PLAYER_MSG7(8,"PassThrough: Forwarding SRC->DST Interface code=%d %d:%d:%d -> %d:%d:%d",hdr->addr.interf, hdr->addr.host,hdr->addr.robot, hdr->addr.index, dstAddr.host, dstAddr.robot, dstAddr.index); hdr->addr=dstAddr; //will send to my clients, making it seem like it comes from my DST interface @@ -353,7 +353,7 @@ if (Device::MatchDeviceAddress(hdr->addr,dstAddr) && (hdr->type == PLAYER_MSGTYPE_CMD)) { - PLAYER_MSG7(8,"PassThrough: Forwarding DST->SRC Interface code=%d %d:%d:%d -> %d:%d:%d",hdr->addr.interf, hdr->addr.host,hdr->addr.robot, hdr->addr.index, srcAddr.host, srcAddr.robot, srcAddr.index); + //PLAYER_MSG7(8,"PassThrough: Forwarding DST->SRC Interface code=%d %d:%d:%d -> %d:%d:%d",hdr->addr.interf, hdr->addr.host,hdr->addr.robot, hdr->addr.index, srcAddr.host, srcAddr.robot, srcAddr.index); hdr->addr=srcAddr; //send to the device to which I subscribed, making it seem like it comes from my original interface @@ -410,7 +410,7 @@ void PassThrough::Main() { //The forwarding is done in the ProcessMessage method. Called once per each message by ProcessMessages() - while (true) + while (true) { InQueue->Wait(); ProcessMessages(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit