##// END OF EJS Templates
Merge
leroy -
r8:7f877774dc5c merge default
parent child
Show More
@@ -7,5 +7,4 unix:LPPMONCFG = /etc/lppmon
7 SUBDIRS = \
7 SUBDIRS = \
8 rmapplugin
8 rmapplugin
9
9
10
11 #include( $${LPPMONCFG}/lppmonplugin.prf)
10 #include( $${LPPMONCFG}/lppmonplugin.prf)
@@ -3,4 +3,154
3 bridge::bridge(QWidget *parent) :
3 bridge::bridge(QWidget *parent) :
4 QWidget(parent)
4 QWidget(parent)
5 {
5 {
6 // Packet receiver
7 rmapPacketSEMAPHORE = new QSemaphore;
8 ccsdsPacketSEMAPHORE = new QSemaphore;
9 rmapPacket = (char*) malloc(RMAP_MAX_PACKET_LENGTH);
10 ccsdsPacket = (unsigned char*) malloc(CCSDS_MAX_PACKET_LENGTH);
11 spwPacket = (char*) malloc( qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH) );
12
13 bridge_LAYOUT = new QGridLayout;
6 }
14 }
15
16 bridge::~bridge()
17 {
18 free(rmapPacket);
19 free(ccsdsPacket);
20 free(spwPacket);
21 }
22
23 unsigned int bridge::Write(unsigned int *Value, unsigned int count, unsigned int address)
24 {
25 unsigned int remainingCount = count;
26 unsigned int iOffset = 0;
27 QString console_message;
28 char* data;
29
30 if(rmapPacketSEMAPHORE->available()!=0)
31 {
32 emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP request already running, WRITE access stopped");
33 return 1;
34 }
35
36 emit this->RMAP_write_reply_setText("reply to the write command required\nlast reply status: unavailable");
37
38 data = (char*) malloc(READ_WRITE_MAX_COUNTS*4);
39
40 emit appendToLog(QString("*** START *** WRITE ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16));
41
42 while (remainingCount > READ_WRITE_MAX_COUNTS)
43 {
44 for (int i = 0; i<READ_WRITE_MAX_COUNTS; i++)
45 {
46 data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]);
47 data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8);
48 data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16);
49 data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24);
50 }
51
52 console_message.sprintf("remainingCount: %d => ", remainingCount);
53 emit appendToLog(console_message + QString("Write ")+ QString::number(READ_WRITE_MAX_COUNTS*4) + QString(" byte(s) @0x")+ QString::number(address,16));
54
55 if(WriteBLOCK(data, READ_WRITE_MAX_COUNTS*4, address)==0)
56 {
57 emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed");
58 return 1;
59 }
60
61 remainingCount = remainingCount - READ_WRITE_MAX_COUNTS;
62 address = address + READ_WRITE_MAX_COUNTS * 4;
63 iOffset = iOffset + READ_WRITE_MAX_COUNTS;
64 }
65
66 if (remainingCount > 0)
67 {
68 for (unsigned int i = 0; i<remainingCount; i++)
69 {
70 data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]);
71 data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8);
72 data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16);
73 data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24);
74 }
75
76 console_message.sprintf("remainingCount: %d => ", remainingCount);
77 emit appendToLog(console_message + QString("Write ")+ QString::number(remainingCount*4) + QString(" byte(s) @0x")+ QString::number(address,16));
78
79 if (WriteBLOCK(data, remainingCount*4, address)==0)
80 {
81 emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed");
82 return 1;
83 }
84 }
85
86 emit appendToLog(QString("*** STOP *** WRITE"));
87 free(data);
88 return count;
89 }
90
91 unsigned int bridge::Read(unsigned int *Value, unsigned int count, unsigned int address)
92 {
93 unsigned int remainingCount = count;
94 unsigned int iOffset = 0;
95 QString console_message;
96
97 if(rmapPacketSEMAPHORE->available()!=0)
98 {
99 emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP request already running, READ access stopped");
100 return 1;
101 }
102 emit appendToLog(QString("*** START *** READ ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16));
103
104 while (remainingCount > READ_WRITE_MAX_COUNTS)
105 {
106 console_message.sprintf("remainingCount: %d => ", remainingCount);
107 emit appendToLog(console_message + QString("Read ")+ QString::number(4*READ_WRITE_MAX_COUNTS) + QString(" byte(s) @0x")+ QString::number(address,16));
108
109 if (this->ReadBLOCK(READ_WRITE_MAX_COUNTS*4, address)==0)
110 {
111 emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received");
112 return 1;
113 }
114
115 for(int i=0;i<READ_WRITE_MAX_COUNTS;i++)
116 {
117 Value[i+iOffset] = (unsigned char) rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH];
118 for(int j=1;j<4;j++)
119 {
120 Value[i+iOffset]= ((unsigned char) (rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH]))
121 + Value[i+iOffset]*256;
122 }
123 }
124
125 remainingCount = remainingCount - READ_WRITE_MAX_COUNTS;
126 address = address + READ_WRITE_MAX_COUNTS * 4;
127 iOffset = iOffset + READ_WRITE_MAX_COUNTS;
128 rmapPacketSEMAPHORE->acquire();
129 }
130
131 if (remainingCount > 0)
132 {
133 console_message.sprintf("remainingCount: %d => ", remainingCount);
134 emit appendToLog(console_message + QString("Read ")+ QString::number(4*remainingCount) + QString(" byte(s) @0x")+ QString::number(address,16));
135
136 if (this->ReadBLOCK(4*remainingCount, address)==0)
137 {
138 emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received");
139 return 1;
140 }
141
142 for(unsigned int i=0;i<remainingCount;i++)
143 {
144 Value[i+iOffset] = (unsigned char) rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH];
145 for(int j=1;j<4;j++)
146 {
147 Value[i+iOffset]= ((unsigned char)(rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) + Value[i+iOffset]*256;
148 }
149 }
150 rmapPacketSEMAPHORE->acquire();
151 }
152
153 emit appendToLog(QString("*** STOP *** READ "));
154 return count;
155 }
156
@@ -2,17 +2,53
2 #define BRIDGE_H
2 #define BRIDGE_H
3
3
4 #include <QWidget>
4 #include <QWidget>
5 #include <QSemaphore>
6 #include <QGridLayout>
7 #include "rmapoperations.h"
5
8
6 class bridge : public QWidget
9 class bridge : public QWidget
7 {
10 {
8 Q_OBJECT
11 Q_OBJECT
9 public:
12 public:
10 explicit bridge(QWidget *parent = 0);
13 explicit bridge(QWidget *parent = 0);
11
14 ~bridge();
15 unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0);
16 unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0);
17 virtual unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication);
18 virtual unsigned int WriteBLOCK(char *data,unsigned int nbBytes,unsigned int address=0) = 0;
19 virtual unsigned int ReadBLOCK(unsigned int nbBytes,unsigned int address=0) = 0;
20 virtual unsigned int getLinkStatus(unsigned char link) = 0;
21
22 unsigned char rmapTargetLogicalAddress ;
23 unsigned char rmapSourceLogicalAddress ;
24
25 RMAP_command_codes commandCode;
26
27 QGridLayout *bridge_LAYOUT;
28
29 QSemaphore *rmapPacketSEMAPHORE;
30 QSemaphore *ccsdsPacketSEMAPHORE;
31
32 char *spwPacket;
33 char* rmapPacket;
34 unsigned char *ccsdsPacket;
35
12 signals:
36 signals:
37 void sendMessage(QString message);
38 void isOpen(bool);
39 void RMAP_write_reply_setText(QString);
40 void appendToLog(QString);
41 void ccsdsPacketAvailable(unsigned char*, unsigned int);
13
42
14 public slots:
43 public slots:
15
44 unsigned int Open();
45 unsigned int Close();
46 virtual int receiveSPWPacket(unsigned char requestID) = 0;
47 void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;}
48 void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;}
49 void sourceHasChanged(int target) {rmapSourceLogicalAddress = (unsigned char) target;}
50
51 private:
16 };
52 };
17
53
18 #endif // BRIDGE_H
54 #endif // BRIDGE_H
@@ -18,10 +18,8 DEFINES += driver_can_be_child=0
18 DEFINES += driver_VID=0
18 DEFINES += driver_VID=0
19 DEFINES += driver_PID=0
19 DEFINES += driver_PID=0
20
20
21
22 QT += network
21 QT += network
23
22
24
25 LIBS += ../spw_usb_driver_v2.61/lib/x86_64/libSpaceWireUSBAPI.so \
23 LIBS += ../spw_usb_driver_v2.61/lib/x86_64/libSpaceWireUSBAPI.so \
26 ../spw_usb_driver_v2.61/lib/x86_64/libConfigLibraryUSB.so
24 ../spw_usb_driver_v2.61/lib/x86_64/libConfigLibraryUSB.so
27
25
@@ -72,4 +70,3 SOURCES += \
72
70
73
71
74
72
75
General Comments 0
You need to be logged in to leave comments. Login now