NetTalk Central

Author Topic: Net Simple client  (Read 10953 times)

ramiro

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Email
Net Simple client
« 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.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Net Simple client
« Reply #1 on: February 28, 2013, 09:58:09 PM »
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

ramiro

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Email
Re: Net Simple client
« Reply #2 on: March 01, 2013, 09:28:18 AM »
Bruce,
thank you very much, I will try to implement your comments

regards,
Ramiro

ramiro

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Email
Re: Net Simple client
« Reply #3 on: March 04, 2013, 09:15:50 AM »
Hi Bruce,
Your suggestion to change the order of the bytes most significant work.
thank you very much

Regards,

Ramiro M B