@@ -1,11 +1,10 | |||||
1 | TEMPLATE = subdirs |
|
1 | TEMPLATE = subdirs | |
2 | CONFIG += ordered |
|
2 | CONFIG += ordered | |
3 |
|
3 | |||
4 | win32:LPPMONCFG = /opt/lppmon |
|
4 | win32:LPPMONCFG = /opt/lppmon | |
5 | unix:LPPMONCFG = /etc/lppmon |
|
5 | unix:LPPMONCFG = /etc/lppmon | |
6 |
|
6 | |||
7 | SUBDIRS = \ |
|
7 | SUBDIRS = \ | |
8 | rmapplugin |
|
8 | rmapplugin | |
9 |
|
9 | |||
10 |
|
||||
11 | #include( $${LPPMONCFG}/lppmonplugin.prf) |
|
10 | #include( $${LPPMONCFG}/lppmonplugin.prf) |
@@ -1,6 +1,156 | |||||
1 | #include "bridge.h" |
|
1 | #include "bridge.h" | |
2 |
|
2 | |||
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 |
@@ -1,18 +1,54 | |||||
1 | #ifndef BRIDGE_H |
|
1 | #ifndef BRIDGE_H | |
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 |
@@ -1,75 +1,72 | |||||
1 | # |
|
1 | # | |
2 | # Project created by QtCreator 2011-09-20T08:15:30 |
|
2 | # Project created by QtCreator 2011-09-20T08:15:30 | |
3 | # |
|
3 | # | |
4 | #------------------------------------------------- |
|
4 | #------------------------------------------------- | |
5 |
|
5 | |||
6 | #include(/etc/lppmon/lppmonplugin.prf) |
|
6 | #include(/etc/lppmon/lppmonplugin.prf) | |
7 | CONFIG += lppmonplugin |
|
7 | CONFIG += lppmonplugin | |
8 | TARGET = rmapplugin |
|
8 | TARGET = rmapplugin | |
9 |
|
9 | |||
10 | DEFINES += PLUGIN=rmapplugin |
|
10 | DEFINES += PLUGIN=rmapplugin | |
11 | DEFINES += PLUGINHEADER="\"\\\"rmapplugin.h"\\\"\" |
|
11 | DEFINES += PLUGINHEADER="\"\\\"rmapplugin.h"\\\"\" | |
12 | DEFINES += driver_Name="\"\\\"RMAPPlugin"\\\"\" |
|
12 | DEFINES += driver_Name="\"\\\"RMAPPlugin"\\\"\" | |
13 | DEFINES += driver_Author="\"\\\"Paul Leroy paul.leroy@lpp.polytechnique.fr"\\\"\" |
|
13 | DEFINES += driver_Author="\"\\\"Paul Leroy paul.leroy@lpp.polytechnique.fr"\\\"\" | |
14 | DEFINES += driver_Version="\"\\\"1.1.2"\\\"\" |
|
14 | DEFINES += driver_Version="\"\\\"1.1.2"\\\"\" | |
15 | DEFINES += driver_Description="\"\\\"AHB bus controler, works with Gaisler's AHB plugn' play bus."\\\"\" |
|
15 | DEFINES += driver_Description="\"\\\"AHB bus controler, works with Gaisler's AHB plugn' play bus."\\\"\" | |
16 | DEFINES += driver_can_be_root=1 |
|
16 | DEFINES += driver_can_be_root=1 | |
17 | DEFINES += driver_can_be_child=0 |
|
17 | 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 | |||
28 |
|
26 | |||
29 | INCLUDEPATH += \ |
|
27 | INCLUDEPATH += \ | |
30 | $${PWD} \ |
|
28 | $${PWD} \ | |
31 | ../common_PLE \ |
|
29 | ../common_PLE \ | |
32 | ../spw_usb_driver_v2.61/inc |
|
30 | ../spw_usb_driver_v2.61/inc | |
33 |
|
31 | |||
34 |
|
32 | |||
35 | HEADERS += \ |
|
33 | HEADERS += \ | |
36 | rmappluginui.h \ |
|
34 | rmappluginui.h \ | |
37 | rmapplugin.h \ |
|
35 | rmapplugin.h \ | |
38 | rmapoperations.h \ |
|
36 | rmapoperations.h \ | |
39 | ccsds.h \ |
|
37 | ccsds.h \ | |
40 | spwpacketreceiver.h \ |
|
38 | spwpacketreceiver.h \ | |
41 | ../common_PLE/qipdialogbox.h \ |
|
39 | ../common_PLE/qipdialogbox.h \ | |
42 | ../common_PLE/gresbstatusenquiry.h \ |
|
40 | ../common_PLE/gresbstatusenquiry.h \ | |
43 | spectralmatricesdmasimulator.h \ |
|
41 | spectralmatricesdmasimulator.h \ | |
44 | rmappluginpythonwrapper.h \ |
|
42 | rmappluginpythonwrapper.h \ | |
45 | stardundee.h \ |
|
43 | stardundee.h \ | |
46 | ../spw_usb_driver_v2.61/inc/spw_usb_api.h \ |
|
44 | ../spw_usb_driver_v2.61/inc/spw_usb_api.h \ | |
47 | ../spw_usb_driver_v2.61/inc/spw_config_library.h \ |
|
45 | ../spw_usb_driver_v2.61/inc/spw_config_library.h \ | |
48 | gresb.h \ |
|
46 | gresb.h \ | |
49 | bridge.h |
|
47 | bridge.h | |
50 |
|
48 | |||
51 |
|
49 | |||
52 | SOURCES += \ |
|
50 | SOURCES += \ | |
53 | rmapplugin.cpp \ |
|
51 | rmapplugin.cpp \ | |
54 | rmappluginui.cpp \ |
|
52 | rmappluginui.cpp \ | |
55 | rmapoperations.cpp \ |
|
53 | rmapoperations.cpp \ | |
56 | ccsds.cpp \ |
|
54 | ccsds.cpp \ | |
57 | spwpacketreceiver.cpp \ |
|
55 | spwpacketreceiver.cpp \ | |
58 | ../common_PLE/qipdialogbox.cpp \ |
|
56 | ../common_PLE/qipdialogbox.cpp \ | |
59 | ../common_PLE/gresbstatusenquiry.cpp \ |
|
57 | ../common_PLE/gresbstatusenquiry.cpp \ | |
60 | spectralmatricesdmasimulator.cpp \ |
|
58 | spectralmatricesdmasimulator.cpp \ | |
61 | rmappluginpythonwrapper.cpp \ |
|
59 | rmappluginpythonwrapper.cpp \ | |
62 | stardundee.cpp \ |
|
60 | stardundee.cpp \ | |
63 | gresb.cpp \ |
|
61 | gresb.cpp \ | |
64 | bridge.cpp |
|
62 | bridge.cpp | |
65 |
|
63 | |||
66 |
|
64 | |||
67 |
|
65 | |||
68 |
|
66 | |||
69 |
|
67 | |||
70 |
|
68 | |||
71 |
|
69 | |||
72 |
|
70 | |||
73 |
|
71 | |||
74 |
|
72 | |||
75 |
|
General Comments 0
You need to be logged in to leave comments.
Login now