Tested building on Windows with Qt Creator and Microsoft VS2010 compiler without MinGW. The code generally works, but I had to make the following changes so far:
Microsoft compilers do not like zero-sized arrays in the middle of a struct, so rewritten:
class iec104_class
{
...
private:
...
unsigned char masterAddress; // master link address
unsigned char slaveAddress; // slave link address
to
private:
...
unsigned char masterAddress; // master link address
unsigned short slaveAddress; // slave link address
because otherwise was getting
--> ASDU WITH UNEXPECTED ORIGIN! Ignoring...
with the cause of that rooted to
papdu->asduh.ca = 888; slaveAddress = 120
(that is, after tweaking the ui part into even allowing to enter such an address)
Given that
struct iec_obj {
...
unsigned short ca; // common addres of asdu
I find the "slave link address" text counterintuitive, and limiting whatever is being compared with a short to size of a byte not well-founded.
Also, can you please detabify everything and use spaces only? That would make it easier to view and use your code as-is without reformatting and thus also easier to submit any patches.
Otherwise, great job! Thank you very much!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Tested building on Windows with Qt Creator and Microsoft VS2010 compiler without MinGW. The code generally works, but I had to make the following changes so far:
struct iec_stcd {
union {
unsigned short st;
struct {
unsigned char st1 :1;
unsigned char st2 :1;
unsigned char st3 :1;
unsigned char st4 :1;
unsigned char st5 :1;
unsigned char st6 :1;
unsigned char st7 :1;
unsigned char st8 :1;
unsigned char st9 :1;
unsigned char st10 :1;
unsigned char st11 :1;
unsigned char st12 :1;
unsigned char st13 :1;
unsigned char st14 :1;
unsigned char st15 :1;
unsigned char st16 :1;
};
};
union {
unsigned short cd;
struct {
unsigned char cd1 :1;
unsigned char cd2 :1;
unsigned char cd3 :1;
unsigned char cd4 :1;
unsigned char cd5 :1;
unsigned char cd6 :1;
unsigned char cd7 :1;
unsigned char cd8 :1;
unsigned char cd9 :1;
unsigned char cd10 :1;
unsigned char cd11 :1;
unsigned char cd12 :1;
unsigned char cd13 :1;
unsigned char cd14 :1;
unsigned char cd15 :1;
unsigned char cd16 :1;
};
};
};
class iec104_class
{
...
private:
...
unsigned char masterAddress; // master link address
unsigned char slaveAddress; // slave link address
to
private:
...
unsigned char masterAddress; // master link address
unsigned short slaveAddress; // slave link address
because otherwise was getting
--> ASDU WITH UNEXPECTED ORIGIN! Ignoring...
with the cause of that rooted to
papdu->asduh.ca = 888; slaveAddress = 120
(that is, after tweaking the ui part into even allowing to enter such an address)
Given that
struct iec_obj {
...
unsigned short ca; // common addres of asdu
I find the "slave link address" text counterintuitive, and limiting whatever is being compared with a short to size of a byte not well-founded.
Also, can you please detabify everything and use spaces only? That would make it easier to view and use your code as-is without reformatting and thus also easier to submit any patches.
Otherwise, great job! Thank you very much!
Those are very nice suggestions, all accepted.
Thank you Mr. Ryabtsev