I want to have the standard Client FB communicate with a C# server
program by means of socket programing.
I saw that the format that the Client FB sends to the server is:
U \0 \5 \0 h \0 a \0 l \0 l \0 o \0
where \0 is a character with value 0 and \5 is a character with value
5 showing 5 characters where send with the message "hallo". I decoded
the string in C# and assumed that the Client FB wil recieve the same
format. But if I send the same string back, the Client FB outputs the
correct "hallo" string but the FB STATUS change to "INVALID OBJECT".
Is there a quick way to fix this? I looked at the ASN.1 encoding but
Im having a hard time to figure it out.
As a mechanical engineer, this is unknown ground, so sorry if it is a
silly question. :)
ASN.1 is a Tag/Length/Value notation. Your example is missing the Tag and half of the Length for the STRING data type. The correct contents of the message in hexadecimal notation would be 50 00 05 68 61 6C 6C 6F Here the Tag is 50, Length is 0005 and Value is as indicated.
For some data types the Length value is implicit in the Tag type; for others (such as STRING) it is often encoded more simply than the more complex rules given for ASN.1.
You can learn the formatting of messages by using the CODEC_TEST configuration in the src/ita folder. Instructions for using this configuration are at http://www.holobloc.com/doc/ita/panels/index.htm . -- Best regards, Jim Christensen
On Tue, Oct 11, 2011 at 12:34 AM, Anro le Roux <alerou...@gmail.com> wrote:
> I want to have the standard Client FB communicate with a C# server > program by means of socket programing.
> I saw that the format that the Client FB sends to the server is:
> U \0 \5 \0 h \0 a \0 l \0 l \0 o \0
> where \0 is a character with value 0 and \5 is a character with value > 5 showing 5 characters where send with the message "hallo". I decoded > the string in C# and assumed that the Client FB wil recieve the same > format. But if I send the same string back, the Client FB outputs the > correct "hallo" string but the FB STATUS change to "INVALID OBJECT".
> Is there a quick way to fix this? I looked at the ASN.1 encoding but > Im having a hard time to figure it out.
> As a mechanical engineer, this is unknown ground, so sorry if it is a > silly question. :)
//assumed the same , 55 00 05 00 68 00 61 00 6C 00 6C
00 6F, and buffer length 13, gives "hallo" and "OK"
//from the CODEC_TEST , 50 00 00 55 00 05 00 68 00 61 00 6C 00 6C
00 6F, and buffer length 16, gives "桡汬漀 o" and "INVALID_OBJECT"
//suggested , 55 00 05 68 61 6C 6C
6F , and buffer length 8 , gives "" and "OK"
n = write(newsockfd,buffer,13);
as you can see I tried everything (spend much time) and finally got it
working with the way I used all along. Embarrassed... the trick was to
set the numbers of bytes sent, in the write command, correctly ...
oops.
Your time and assistance are much appreciated, I would have given up
if it wasn't for your help.
Regards
Anro
On Oct 11, 4:07 pm, James Christensen <james.h.christen...@gmail.com>
wrote:
> ASN.1 is a Tag/Length/Value notation. Your example is missing the Tag
> and half of the Length for the STRING data type.
> The correct contents of the message in hexadecimal notation would be
> 50 00 05 68 61 6C 6C 6F
> Here the Tag is 50, Length is 0005 and Value is as indicated.
> For some data types the Length value is implicit in the Tag type; for
> others (such as STRING) it is often encoded more simply than the more
> complex rules given for ASN.1.
> You can learn the formatting of messages by using the CODEC_TEST
> configuration in the src/ita folder. Instructions for using this
> configuration are athttp://www.holobloc.com/doc/ita/panels/index.htm > .
> --
> Best regards,
> Jim Christensen
> On Tue, Oct 11, 2011 at 12:34 AM, Anro le Roux <alerou...@gmail.com> wrote:
> > Hi all,
> > I want to have the standard Client FB communicate with a C# server
> > program by means of socket programing.
> > I saw that the format that the Client FB sends to the server is:
> > U \0 \5 \0 h \0 a \0 l \0 l \0 o \0
> > where \0 is a character with value 0 and \5 is a character with value
> > 5 showing 5 characters where send with the message "hallo". I decoded
> > the string in C# and assumed that the Client FB wil recieve the same
> > format. But if I send the same string back, the Client FB outputs the
> > correct "hallo" string but the FB STATUS change to "INVALID OBJECT".
> > Is there a quick way to fix this? I looked at the ASN.1 encoding but
> > Im having a hard time to figure it out.
> > As a mechanical engineer, this is unknown ground, so sorry if it is a
> > silly question. :)
Yes, for the basic Unicode character set you use the 55 (WSTRING) data type with two bytes per character and a MSB of 00 for each character.
The tag is defined in Annex E.3.2 of IEC 61499-1 as [APPLICATION 21], or in hex: 40 (APPLICATION) + 15 (21 decimal).
The specialized encoding for string types is given in the Compliance Profile at http://www.holobloc.com/doc/ita/index.htm, in subclause 5.4.4.2 which you can access from the Table of Contents.
Hope this helps you navigate around the standard and Compliance Profile if and when you need to encode other data types. -- Best regards, Jim Christensen
On Tue, Oct 11, 2011 at 4:25 PM, Anro le Roux <alerou...@gmail.com> wrote:
> //assumed the same , 55 00 05 00 68 00 61 00 6C 00 6C > 00 6F, and buffer length 13, gives "hallo" and "OK" > //from the CODEC_TEST , 50 00 00 55 00 05 00 68 00 61 00 6C 00 6C > 00 6F, and buffer length 16, gives "桡汬漀 o" and "INVALID_OBJECT" > //suggested , 55 00 05 68 61 6C 6C > 6F , and buffer length 8 , gives "" and "OK"
> n = write(newsockfd,buffer,13);
> as you can see I tried everything (spend much time) and finally got it > working with the way I used all along. Embarrassed... the trick was to > set the numbers of bytes sent, in the write command, correctly ... > oops.
> Your time and assistance are much appreciated, I would have given up > if it wasn't for your help.
> Regards > Anro
> On Oct 11, 4:07 pm, James Christensen <james.h.christen...@gmail.com> > wrote: >> ASN.1 is a Tag/Length/Value notation. Your example is missing the Tag >> and half of the Length for the STRING data type. >> The correct contents of the message in hexadecimal notation would be >> 50 00 05 68 61 6C 6C 6F >> Here the Tag is 50, Length is 0005 and Value is as indicated.
>> For some data types the Length value is implicit in the Tag type; for >> others (such as STRING) it is often encoded more simply than the more >> complex rules given for ASN.1.
>> You can learn the formatting of messages by using the CODEC_TEST >> configuration in the src/ita folder. Instructions for using this >> configuration are athttp://www.holobloc.com/doc/ita/panels/index.htm >> . >> -- >> Best regards, >> Jim Christensen
>> On Tue, Oct 11, 2011 at 12:34 AM, Anro le Roux <alerou...@gmail.com> wrote:
>> > Hi all,
>> > I want to have the standard Client FB communicate with a C# server >> > program by means of socket programing.
>> > I saw that the format that the Client FB sends to the server is:
>> > U \0 \5 \0 h \0 a \0 l \0 l \0 o \0
>> > where \0 is a character with value 0 and \5 is a character with value >> > 5 showing 5 characters where send with the message "hallo". I decoded >> > the string in C# and assumed that the Client FB wil recieve the same >> > format. But if I send the same string back, the Client FB outputs the >> > correct "hallo" string but the FB STATUS change to "INVALID OBJECT".
>> > Is there a quick way to fix this? I looked at the ASN.1 encoding but >> > Im having a hard time to figure it out.
>> > As a mechanical engineer, this is unknown ground, so sorry if it is a >> > silly question. :)
> Yes, for the basic Unicode character set you use the 55 (WSTRING) data
> type with two bytes per character and a MSB of 00 for each character.
> The tag is defined in Annex E.3.2 of IEC 61499-1 as [APPLICATION 21],
> or in hex: 40 (APPLICATION) + 15 (21 decimal).
> The specialized encoding for string types is given in the Compliance
> Profile athttp://www.holobloc.com/doc/ita/index.htm, in subclause
> 5.4.4.2 which you can access from the Table of Contents.
> Hope this helps you navigate around the standard and Compliance
> Profile if and when you need to encode other data types.
> --
> Best regards,
> Jim Christensen
> On Tue, Oct 11, 2011 at 4:25 PM, Anro le Roux <alerou...@gmail.com> wrote:
> > Thank you Mr Christensen,
> > I finally got it working, here is my c server code:
> > //assumed the same , 55 00 05 00 68 00 61 00 6C 00 6C
> > 00 6F, and buffer length 13, gives "hallo" and "OK"
> > //from the CODEC_TEST , 50 00 00 55 00 05 00 68 00 61 00 6C 00 6C
> > 00 6F, and buffer length 16, gives "桡汬漀 o" and "INVALID_OBJECT"
> > //suggested , 55 00 05 68 61 6C 6C
> > 6F , and buffer length 8 , gives "" and "OK"
> > n = write(newsockfd,buffer,13);
> > as you can see I tried everything (spend much time) and finally got it
> > working with the way I used all along. Embarrassed... the trick was to
> > set the numbers of bytes sent, in the write command, correctly ...
> > oops.
> > Your time and assistance are much appreciated, I would have given up
> > if it wasn't for your help.
> > Regards
> > Anro
> > On Oct 11, 4:07 pm, James Christensen <james.h.christen...@gmail.com>
> > wrote:
> >> ASN.1 is a Tag/Length/Value notation. Your example is missing the Tag
> >> and half of the Length for the STRING data type.
> >> The correct contents of the message in hexadecimal notation would be
> >> 50 00 05 68 61 6C 6C 6F
> >> Here the Tag is 50, Length is 0005 and Value is as indicated.
> >> For some data types the Length value is implicit in the Tag type; for
> >> others (such as STRING) it is often encoded more simply than the more
> >> complex rules given for ASN.1.
> >> You can learn the formatting of messages by using the CODEC_TEST
> >> configuration in the src/ita folder. Instructions for using this
> >> configuration are athttp://www.holobloc.com/doc/ita/panels/index.htm > >> .
> >> --
> >> Best regards,
> >> Jim Christensen
> >> On Tue, Oct 11, 2011 at 12:34 AM, Anro le Roux <alerou...@gmail.com> wrote:
> >> > Hi all,
> >> > I want to have the standard Client FB communicate with a C# server
> >> > program by means of socket programing.
> >> > I saw that the format that the Client FB sends to the server is:
> >> > U \0 \5 \0 h \0 a \0 l \0 l \0 o \0
> >> > where \0 is a character with value 0 and \5 is a character with value
> >> > 5 showing 5 characters where send with the message "hallo". I decoded
> >> > the string in C# and assumed that the Client FB wil recieve the same
> >> > format. But if I send the same string back, the Client FB outputs the
> >> > correct "hallo" string but the FB STATUS change to "INVALID OBJECT".
> >> > Is there a quick way to fix this? I looked at the ASN.1 encoding but
> >> > Im having a hard time to figure it out.
> >> > As a mechanical engineer, this is unknown ground, so sorry if it is a
> >> > silly question. :)