Personal Data

Username:
quirzo
Joined:
2020-05-13 05:24:46+00:00

Projects

  • No projects to display.

Skills

  • No skills entered.

User Activity

  • Posted a comment on discussion Engineering 🇬🇧 on CODESYS Forge

    It's how C-style strings work. The system needs to know somehow when it ends and that is done by adding a 0 byte to the end of the text. https://en.wikipedia.org/wiki/Null-terminated_string

  • Posted a comment on discussion Engineering 🇬🇧 on CODESYS Forge

    Remember that STRING takes always one extra byte, as there is always a string end byte. So STRING(16) takes 17 bytes.

  • Posted a comment on discussion Engineering 🇬🇧 on CODESYS Forge

    It might be because of pack mode, which causes padding bytes between structure variables. Try to add {attribute 'pack_mode' := '1'} above the struct definition. In pack mode 1, there are no padding bytes and the copy should work. Example (from Beckhoff site, https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/2529746059.html&id=3686945105176987925): {attribute 'pack_mode' := '1'} TYPE ST_MyStruct: STRUCT bEnable : BOOL; nCounter : INT; nMaxSize : INT; bMaxSizeReached :...

  • Posted a comment on discussion Engineering 🇬🇧 on CODESYS Forge

    From the same page: Constant expressions are not permitted for this purpose. Example: “arrVar : ARRAY[0..g_iArraySize-1] OF INT ;” is not transmitted, but “arrVar : ARRAY[0..10] OF INT ;” is transmitted. So yes. Constants wont work.

  • Posted a comment on discussion Engineering on CODESYS Forge

    One way to get the size is to use SIZEOF() operator. But you have to do it for each GVL variable. //GVL_Test VAR_GLOBAL First : STRING; Second : INT; Third : ST_Struct; END_VAR Then in code somewhere: VAR GvlSize : UDINT; END_VAR GvlSize := 0; GvlSize := GvlSize + SIZEOF(GVL_Test.First); GvlSize := GvlSize + SIZEOF(GVL_Test.Second); GvlSize := GvlSize + SIZEOF(GVL_Test.Third); //Now GvlSize is the size as bytes

  • Posted a comment on discussion Engineering on CODESYS Forge

    Could you please post your current code

  • Posted a comment on discussion Engineering on CODESYS Forge

    Yes, use that byte array to send data. The data was different because if your string has ASCII characters (or WSTRING has unicode). If you have STRING of 73 83 67 80 0 0 0 16 0 0 0 8 1 0 0 0 33 49 80 87 82 48 49 13 you will see in wireshark something like 55 51 32 56 51 32 54 55 32 56 48 32 48 32 48 32 48 32 49 54 32 48 32 48 32 48 32 56 32 49 32 48 32 48 32 48 32 51 51 32 52 57 32 56 48 32 56 55 32 56 50 32 52 56 32 52 57 32 49 51 Where 7 = 55, 3 = 51 and so on.

  • Posted a comment on discussion Engineering on CODESYS Forge

    Oh sorry. I just realized that you have bytes you want to send in that WSTRING, not characters? If so, then that code can't work as the 73 = character seven and three, not byte value 73. Then you need to create an array of bytes and place the data in there: Data : ARRAY[0..200] OF BYTE := [73, 83, 67, 68, 0(*and so on*)];

View All