Activity for Quirzo

  • Quirzo Quirzo posted a comment on discussion Engineering 🇬🇧

    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

  • Quirzo Quirzo posted a comment on discussion Engineering 🇬🇧

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

  • Quirzo Quirzo posted a comment on discussion Engineering 🇬🇧

    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 :...

  • Quirzo Quirzo posted a comment on discussion Engineering 🇬🇧

    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.

  • Quirzo Quirzo posted a comment on discussion Engineering

    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

  • Quirzo Quirzo posted a comment on discussion Engineering

    Could you please post your current code

  • Quirzo Quirzo posted a comment on discussion Engineering

    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.

  • Quirzo Quirzo posted a comment on discussion Engineering

    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*)];

  • Quirzo Quirzo posted a comment on discussion Engineering

    If your other tasks can wait, I would simply create a variable like "alreadySending" and when it's TRUE, other tasks should wait.When it's FALSE, the next who is the fastest would set it to true again and send the command. If that won't work, you would need to create a queue system that takes all given commands in and handles them one-by-one. Then when the command is sent, the command would be taken from the queue and then the calling tasks would be notified somehow.

  • Quirzo Quirzo posted a comment on discussion Engineering

    Use STRING instead of WSTRING so you get directly values as bytes. WSTRING is in unicode so it uses 2 bytes for each character and STRING uses one byte for each character.

1