Skip to content

Commit

Permalink
changes in order to accomodate for the CInterface and CProbe wrapper
Browse files Browse the repository at this point in the history
classes
  • Loading branch information
alxnik committed Dec 3, 2012
1 parent 3625c53 commit f4b1541
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
15 changes: 7 additions & 8 deletions CFroniusProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "CFroniusProbe.h"
#include "errno.h"

extern CLog Logger;

CFroniusProbe::CFroniusProbe(CInterface *SerialLine, string uuid)
{
Expand Down Expand Up @@ -133,7 +132,7 @@ CFroniusProbe::GetAverage(DataContainer &AverageData)

if(m_MsgQueue.size() == 0)
{
syslog(LOG_ERR, "Possible bug. Empty list received\n");
syslog(LOG_ERR, "No messages in Queue\n");
return false;
}

Expand Down Expand Up @@ -455,7 +454,7 @@ CFroniusProbe::ReceivingFunction(void *ptr)
struct ThreadStruct args;
memcpy(&args, ptr, sizeof(struct ThreadStruct));

CInterface Interface = *(args.interface);
CInterface *Interface = args.interface;


uint8_t CurrentMessage[512];
Expand All @@ -468,9 +467,9 @@ CFroniusProbe::ReceivingFunction(void *ptr)
while(true)
{
// Read from serial
if(!Interface.Receive(&in, 1))
if(!Interface->Receive(&in, 1, 1))
{
syslog(LOG_ERR, "Error Reading from Serial Line\n");
syslog(LOG_ERR, "Error Reading from Interface\n");
sleep(1);
continue;
}
Expand Down Expand Up @@ -525,15 +524,15 @@ CFroniusProbe::ReceivingFunction(void *ptr)
if(debugFlag == true)
{
//syslog(LOG_INFO, "Message Received:\n");
//Logger.hexDump(CurrentMessage, MsgPtr);
//Log.hexDump(LOG_DEBUG, CurrentMessage, MsgPtr);
}

// Push the message back to the message queue
struct MsgStruct msg;
msg.DataLen = MsgPtr;
memcpy((void *)msg.Data, CurrentMessage, MsgPtr);
msg.TimeStamp = time(NULL);
msg.Iface = &Interface;
msg.Iface = Interface;

pthread_mutex_lock(args.queueMutex);
args.MsgQueue->push_back(msg);
Expand Down Expand Up @@ -593,7 +592,7 @@ CFroniusProbe::SendMessage(CInterface *interface, uint8_t Command, uint8_t netwo
if(debugFlag == true)
{
//syslog(LOG_INFO, "Sending msg:\n");
//Logger.hexDump(message, ptr);
//Log.hexDump(LOG_DEBUG, message, ptr);
}

if(!interface->Send(message, ptr))
Expand Down
25 changes: 3 additions & 22 deletions CFroniusProbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,13 @@
*/

#ifndef CPROBE_H_
#define CPROBE_H_
#ifndef CFRONIUSPROBE_H_
#define CFRONIUSPROBE_H_
#include "fpd.h"
#include "CLog.h"
#include "CInterface.h"
#include "CSerial.h"
using namespace std;


struct MsgStruct
{
uint8_t Data[128]; // Message data
uint16_t DataLen; // Message length
uint32_t TimeStamp; // Timestamp of message arrival
CInterface *Iface; // The serial interface that received the message
};

struct ThreadStruct
{
CInterface *interface;
list<struct MsgStruct> *MsgQueue;
pthread_mutex_t *queueMutex;

list<int> *connected;
};


class CFroniusProbe : public CProbe
{
public:
Expand Down

0 comments on commit f4b1541

Please sign in to comment.