changeset 126:b2a2c22951fb main

New method to check if the outgoing queue is empty. Can now create messages without data.
author Bob Cook <bob@bobcookdev.com>
date Thu, 15 Dec 2011 06:57:02 -0800
parents ddbad6e9b017
children f1944fbcf419
files main/packages/linux/can/CANMessage.cpp main/packages/linux/can/CANMessage.h
diffstat 2 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/main/packages/linux/can/CANMessage.cpp	Thu Dec 15 06:54:21 2011 -0800
+++ b/main/packages/linux/can/CANMessage.cpp	Thu Dec 15 06:57:02 2011 -0800
@@ -44,6 +44,13 @@
 
 // ----------------------------------------------------------------------------------------
 
+bool CANMessage::IsSendQueueEmpty()
+{
+    return sm_MsgsToSend.empty();
+}
+
+// ----------------------------------------------------------------------------------------
+
 void CANMessage::QueueToSend( CANMessage* msg )
 {
     sm_MsgsToSend.enqueueNotification( msg );
@@ -53,7 +60,7 @@
 
 CANMessage* CANMessage::WaitDequeueToSend( long timeoutMilliseconds )
 {
-    return reinterpret_cast<CANMessage*>(
+    return reinterpret_cast< CANMessage* >(
             sm_MsgsToSend.waitDequeueNotification( timeoutMilliseconds ) );
 }
 
@@ -68,7 +75,7 @@
 
 CANMessage* CANMessage::WaitDequeueReceived( long timeoutMilliseconds )
 {
-    return reinterpret_cast<CANMessage*>(
+    return reinterpret_cast< CANMessage* >(
             sm_MsgsReceived.waitDequeueNotification( timeoutMilliseconds ) );
 }
 
@@ -125,6 +132,15 @@
 
 // ----------------------------------------------------------------------------------------
 
+CANMessage::CANMessage( uint32_t message_id )
+    : Poco::Notification(),
+      m_id( message_id ),
+      m_length( 0 )
+{
+}
+
+// ----------------------------------------------------------------------------------------
+
 CANMessage::CANMessage( uint32_t message_id, const uint8_t* data, uint8_t length )
     : Poco::Notification(),
       m_id( message_id ),
--- a/main/packages/linux/can/CANMessage.h	Thu Dec 15 06:54:21 2011 -0800
+++ b/main/packages/linux/can/CANMessage.h	Thu Dec 15 06:57:02 2011 -0800
@@ -7,7 +7,7 @@
 //    
 //  CAN message object that can be queued or dequeued from multiple threads.
 //
-//  Copyright (c) 2010 Bob Cook
+//  Copyright (c) 2011 Bob Cook
 //
 //  Permission is hereby granted, free of charge, to any person obtaining a copy
 //  of this software and associated documentation files (the "Software"), to deal
@@ -44,6 +44,7 @@
 class CANMessage : public Poco::Notification
 {
     public:
+        static bool IsSendQueueEmpty();
         static void QueueToSend( CANMessage* msg );
         static CANMessage* WaitDequeueToSend( long timeoutMilliseconds );
         static void QueueReceived( CANMessage* msg );
@@ -51,6 +52,7 @@
         static std::string asText( const CANMessage* msg );
 
     public:
+        CANMessage( uint32_t message_id );
         CANMessage( uint32_t message_id, const uint8_t* data, uint8_t length );
         CANMessage* clone() const;
         uint32_t msgIdentifier() const;