(for the future me: DO NOT SPAM THE POST BUTTON)
About the MEMCMP/cast in the Compare function: Yes of course a byte per byte comparison is stupid for REAL and also on other types. I was so excited that I forget to remove this commented line of code of my example... shame on me. We aren't far enough π ... insertion sort is not that bad but merge sort or quick sort will be really more effective. I am looking to adapt the sort provided in the OSCAT lib to run using a pointer (PVOID) instead of a POINTER TO ARRAY[1..32000] OF REAL. I have some issue...
(for the next me: DO NOT SPAM THE POST BUTTON)
About the MEMCPY/cast in the Compare function: Yes of course a byte per byte comparison is stupid for REAL and also on other types. I was so excited that I forget to remove this commented line of code of my example... shame on me. We aren't far enough π ... insertion sort is not that bad but merge sort or quick sort will be really more effective. I am looking to adapt the sort provided in the OSCAT lib to run using a pointer (PVOID) instead of a POINTER TO ARRAY[1..32000] OF REAL. I have some issue...
About the MEMCPY/cast in the Compare function: Yes of course a byte per byte comparison is stupid for REAL and also on other types. I was so excited that I forget to remove this commented line of code of my example... shame on me. We aren't far enough π ... insertion sort is not that bad but merge sort or quick sort will be really more effective. I am looking to adapt the sort provided in the OSCAT lib to run using a pointer (PVOID) instead of a POINTER TO ARRAY[1..32000] OF REAL. I have some issue...
Hi everyone, I have taken a look of your examples. In other languages we pass a comparison function as a parameter of the sorting function. This is not (or it is?) possible using ST language. A way to do it may be to create an ABSTRACT FUNCTION_BLOCK FB_Sort with a private Compare and final Sort method. Then in your code you have to create your own FB_Sort_blablabla (example: FB_Sort_REAL) which derivate (EXTENDS) from the abstract FB_Sort. Then you override the Compare method to fit your needs (like...
Hi everyone, I have taken a look of your examples. In other languages we pass a comparison function as a parameter of the sorting function. This is not (or it is?) possible using ST language. A way to do it may be to create an ABSTRACT FUNCTION_BLOCK FB_Sort with a private Compare and final Sort method. Then in your code you have to create your own FB_Sort_blablabla (example: FB_Sort_REAL) which derivate (EXTENDS) from the abstract FB_Sort. Then you override the Compare method to fit your needs (like...
Hi everyone, I have taken a look of your examples. In other languages we pass a comparison function as a parameter of the sorting function. This is not (or it is?) possible using ST language. A way to do it may be to create an ABSTRACT FUNCTION_BLOCK FB_Sort with a private Compare and final Sort method. Then in your code you have to create your own FB_Sort_blablabla (example: FB_Sort_REAL) which derivate (EXTENDS) from the abstract FB_Sort. Then you override the Compare method to fit your needs (like...
Hi everyone, I have taken a look of your examples. In other languages we pass a comparison function as a parameter of the sorting function. This is not (or it is?) possible using ST language. A way to do it may be to create an ABSTRACT FUNCTION_BLOCK FB_Sort with a private Compare and final Sort method. Then in your code you have to create your own FB_Sort_blablabla (example: FB_Sort_REAL) which derivate (EXTENDS) from the abstract FB_Sort. Then you override the Compare method to fit your needs (like...
Hi everyone, I have taken a look of your examples. In other languages we pass a comparison function as a parameter of the sorting function. This is not (or it is?) possible using ST language. A way to do it may be to create an ABSTRACT FUNCTION_BLOCK FB_Sort with a private Compare and final Sort method. Then in your code you have to create your own FB_Sort_blablabla (example: FB_Sort_REAL) which derivate from the abstract FB_Sort. Then you override the Compare method to fit your needs (like comparing...
Hi everyone, I have taken a look of your examples. In other languages we pass a comparison function as a parameter of the sorting function. This is not (or it is?) possible using ST language. A way to do it may be to create an ABSTRACT FUNCTION_BLOCK FB_Sort with a private Compare and final Sort method. Then in your code you have to create your own FB_Sort_blablabla (example: FB_Sort_REAL) which derivate from the abstract FB_Sort. Then you override the Compare method to fit your needs (like comparing...
Hi everyone, I have taken a look of your examples. In other languages we pass a comparison function as a parameter of the sorting function. This is not (or it is?) possible using ST language. A way to do it may be to create an ABSTRACT FUNCTION_BLOCK FB_Sort with a private Compare and final Sort method. Then in your code you have to create your own FB_Sort_blablabla (example: FB_Sort_REAL) which derivate from the abstract FB_Sort. Then you override the Compare method to fit your needs (like comparing...
Float is 32 bit or 4 bytes and is called REAL in the PLC world. Double is 64 bit or 8 bytes and is calle LREAL in PLC world. with your Value size is too small for a Double, so I'm assuming you will send a float/REAL instead. Simply do: MEMCPY(ADR(Clinet_Tx1[8]), ADR(my_REAL_type_value), SIZEOF(my_REAL_type_value)); /// Going deeper on the topic /// With what I see, instead of an array, the best to do is to create a STRUCT type with all your needed fields in it. Like this (create a new DUT file with...
Float is 32 bit or 4 bytes and is called REAL in the PLC world. Double is 64 bit or 8 bytes and is calle LREAL in PLC world. with your Value size is too small for a Double, so I'm assuming you will send a float/REAL instead. Simply do: MEMCPY(ADR(Clinet_Tx1[8]), ADR(my_REAL_type_value), SIZEOF(my_REAL_type_value)); /// Going deeper on the topic /// With what I see, instead of an array, the best to do is to create a STRUCT type with all your needed fields in it. Like this (create a new DUT file with...
Float is 32 bit or 4 bytes and is called REAL in the PLC world. Double is 64 bit or 8 bytes and is calle LREAL in PLC world. with your Value size is too small for a Double, so I'm assuming you will send a float/REAL instead. Simply do: MEMCPY(ADR(Clinet_Tx1[8]), ADR(my_REAL_type_value), SIZEOF(my_REAL_type_value)); /// Going deeper on the topic /// With what I see, instead of an array, the best to do is to create a STRUCT type with all your needed fields in it. Like this (create a new DUT file with...
Arf good point. C programer habbits... I have edited my post
Hi, The simpliest method is to consider your 12 bytes value as "not null terminated" string. When this case appears to me, I declare a byte array of the needed size (in your case 12 bytes) this way: my_arr_value : ARRAY[0..11] OF BYTE; // some array Then when I will write/copy to/from this array, I simply use MEMCPY(dest, source, n) standard function: // copy TCP_Write_0 in my_arr_value // in this case, SIZEOF(TCP_Write_0) must be greater or equal than SIZEOF(my_arr_value) MEMCPY(ADR(my_arr_value),...
Hi, First, do you have a logic analyser (may be integrated inside your oscilloscope)? Such a tool is a game changer when it comes to debug UART/I2C/SPI/... signals. If you can provide some pictures of the SPI signals, this will be perfect. As documented in page 7 of your datasheet, MOSI information are valid/read on the rising edge of the CLK signal. Be sure to "output" some signals with the correct timing (you can do it without slave connected). instead of Mode 0, try another mode just to see what...
Hi, First, do you have a logic analyser (may be integrated inside your oscilloscope)? Such a tool is a game changer when it comes to debug UART/I2C/SPI/... signals. If you can provide some pictures off the SPI signals, this will be perfect. As documented in page 7 of your datasheet, MOSI information are valid/read on the rising edge of the CLK signal. Be sure to "output" some signals with the correct timing (you can do it without slave connected). instead of Mode 0, try another mode just to see what...
Hi, The simpliest method is to consider your 12 bytes value as "not null terminated" string. When this case appears to me, I declare a byte array of the needed size (in your case 12 bytes) this way: my_arr_value : ARRAY[0..11] OF BYTE; // some array Then when I will write/copy to/from this array, I simply use MEMCPY(dest, source, n) standard function: // copy TCP_Write_0 in my_arr_value // in this case, SIZEOF(TCP_Write_0) must be greater or equal than SIZEOF(my_arr_value) MEMCPY(my_arr_value, TCP_Write_0,...
Hi, I don't know what you will do with this 12 bytes number. The simpliest method is to consider your 12 bytes value as "not null terminated" string. When this case appears to me, I declare a byte array of the needed size (in your case 12 bytes) this way: my_arr_value : ARRAY[0..11] OF BYTE; // some array Then when I will write/copy to/from this array, I simply use MEMCPY(dest, source, n) standard function: // copy TCP_Write_0 in my_arr_value // in this case, SIZEOF(TCP_Write_0) must be greater or...