NetTalk Central
The Rest Of NetTalk => The Rest - Ask For Help => Topic started by: ramiro on February 28, 2013, 10:23:00 AM
-
I need to connect to a service with NetSimple.
The service expects each request contains a header according to the following structure (C++):
typedef structure {
uint32 synch1; /* message synch1 = 0x55555555 */
uint32 synch2; /* message synch2 = 0xaaaaaaaa */
unit16 version; /* format version = 1 */
uint32 cmmd; /* command */
uint32 Bsize; /* Body size */
} spmifhdr;
equivalent structure in Clarion:
PMShdr GROUP, pre(hdr)
synch1 ULONG
synch2 ULONG
version USHORT
cmmd ULONG
bsize ULONG
END
According to the initial values:
synch1 = 055555555h
synch2 = 0aaaaaaaah
version = 1
cmmd = 1
bsize = 42
and applying my conversion the resulting string to send with NetSimple is:
'<85><85><85><85><170><170><170><170><0><1><0><0><0><1><0><0><0><42>.......'
the problem is that the service does not respond and I suspect that my conversion is not correct.
any help will be greatly appreciated
Ramiro M B.
-
Hi Ramiro,
couple of comments;
a) Clarion handles hex numbers. Saves a bit of effort, and maybe mistakes in converting;
'<55h><55h><55h><55h><0aah><0aah><0aah><0aah><0><1><0><0><0><1><0><0><0><42>.......'
you can also comma separate the chars inside < and >. ie
'<55h,55h,55h,55h,0aah,0aah,0aah,0aah,0,1,0,0,0,1,0,0,0,42>.......'
of course that won't change anything.
b) you are assuming that the "least significant byte" in a number is on the Right of the 4 bytes. I can't remember off-hand which way around it goes (and of course it can vary depending on the equipment you are sending to) but you might need to do;
'<55h,55h,55h,55h,0aah,0aah,0aah,0aah,1,0,1,0,0,0,42,0,0,0>.......'
alternatively you could do;
hdr.synch1 = 055555555h
hdr.synch1 = 0AAAAAAAAh
hdr1.version = 1
hdr.cmmd = 42
net.send(PMShdr)
Incidentally the "body" parameter implies there's more to send, but I presume you're just concentrating on the header here.
cheers
Bruce
-
Bruce,
thank you very much, I will try to implement your comments
regards,
Ramiro
-
Hi Bruce,
Your suggestion to change the order of the bytes most significant work.
thank you very much
Regards,
Ramiro M B