Post by ph0010421 on ModbusTCP_FunctionCode06
CODESYS Forge
talk
(Post)
Hi You can add a channel to the standard Modbus TCP library with FC06. From the device tree, add Ethernet device, ModbusTCP master then finally a ModbusTCP slave (your power meter). You can add read/write channels (for any FC) in here. As you add these devices, the necessary libraries will be inserted for you. Alternatively, I have a ModbusTCP client/server library if your RT doesn't have Modbus (I think they all do these days?)
Last updated: 2026-05-18
Post by tommyk-mar on Smooth path is not working with SMC_NCInterpreter
CODESYS Forge
talk
(Post)
Hello, Im using SMC_NCInterpreter and SMC_NCReadFile2 to read gcode program for CNC machine and what I have observed is that G51 and G52 is not smoothing the path. Machine stops in every point, what could I do to make machine pass through the points without stopping or what could allow me to use smooth path corretly if I use NCInterpreter. Im using it because I want to add variables to my gcode and its not possible directly from the CNC editor thats why I do use external file. Any ideas?
Last updated: 2026-03-26
Post by darwin03 on Mismatch between coordinate monitor and actual motion using SMC_GroupJog2, MC_MoveLinearAbsolute (6DOF)
CODESYS Forge
talk
(Post)
Hi Guys!!! I am experiencing an issue when trying to move 6DOF using SMC_GroupJog2 and MC_MoveLinearAbsolute, but I don't understand why, when I jog only X or Y, the coordinate I monitor just changes the X or Y value. It's true, but in reality, Joint6 is still running like the video. Am I wrong somewhere? Many thanks for considering my request.! Video: https://drive.google.com/drive/folders/1vRHQ3AtTO3mijptqZgn5OcP9pyi527Jm?usp=sharing
Last updated: 2026-04-06
Post by struccc on Inheritence of struct,
CODESYS Forge
talk
(Post)
Strangely reminds me to my struggles... Want to do something "Elegant", reusable, universal, practical... In CODESYS??? π First of all, before you get too deep into this: If you could find a way, to make a "universal" log entry object, containing the variable length data itself, you wouldn't be able to store them in an array, or access them like an array, or pass them by value as a type. (please correct me, if I'm wrong, incorrect, or not precise). Because... Basically you can't declare a type with variable memory footprint. This is a very deeply embedded characteristic of CODESYS, and all IEC 61131-3 systems, and it has many reasons behind. And yes, it is a very common trap / mistake, to forget about. So, with a log entry - I guess - it's pretty much the purpose: store data and metadata together, and then handle it in a uniform way. There are ways to handle this, really depends on what is the purpose. For example: 1. Entries with fixed length (Maybe it is not as evil as it looks for the first time. Depends on the situation, but definitely the fastest and easiest code) You can have your base object, with an internal, fixed length string or byte array variable. I would go with a string, and call it _Data.; And then you can make properties, like As_Bool, As_Int, As_Real... In the 'set' accessors, you can do like: pReal := ADR(_Data); // POINTER TO REAL As_Real := pReal^; In the 'get' accessors, evidently: pReal := ADR(_Data); // POINTER TO REAL pReal^ := AS_Real; Or, can use ANY type, if you are not obsessed with variable / property like access: 2. Fixed length, but nicer First, some disadvantage to any values: - You can only assign values with write access. No literals, constants, etc... - Can only be used as input variable of function or function_block - Therefore, stg you could reach: LogEntry.Initialize (stVariable|rVariable|iVariable|xVariable); Just a quick example (it's funny to play with ANY): Be careful it was not tested. I'm sure can be done better, please feel free to comment FUNCTION_BLOCK FB_LogEntry VAR_INPUT MsgClass : UDINT; // Like DEBUG, WARN, ERR... MsgCode : UDINT; // Like Errors.ERR_FAILED MsgTS : DT; // The timestamp END_VAR VAR _Data : STRING(80); // Our data container... _Descr : __SYSTEM.AnyType; // A standard descriptor for our data, containing TYPE_CLASS, address and size END_VAR METHOD SET_Value : BOOL VAR_INPUT anyValue : ANY; END_VAR VAR I : DINT; diSize : DINT; pStr : POINTER TO STRING; END_VAR // Check what did we receive in anyValue. diSize := anyValue.diSize; // We use constant __SYSTEM.TYPE_CLASS to identify the received data type CASE anyValue.TypeClass OF // Maybe we don't want to store references, pointers... and who knows what else... __SYSTEM.TYPE_CLASS.TYPE_REFERENCE, __SYSTEM.TYPE_CLASS.TYPE_POINTER : SET_Value := FALSE; // For the planned types we will be just fine. TYPE_CLASS.TYPE_BOOL, TYPE_CLASS.TYPE_INT, TYPE_CLASS.TYPE_REAL : SET_Value := TRUE; // Optionally string can be handled separately, maybe we have received STRING(255), but practically it is shorter than 80 bytes... TYPE_CLASS.TYPE_STRING : pStr := anyValue.pValue; diSize := MIN(anyValue.diSize, LEN(pStr^) + 1); // Get the actual size, and rewrite the received structure member diSize := MIN(SIZEOF(_Data), diSize); // Can chop down the received string to our length... SET_Value := TRUE; // Maybe want to play a little bit more here, to narrow down or convert datatypes, etc... // Or just reject any other datatype ELSE SET_Value := FALSE; RETURN; END_CASE // Fail, if the received value is still larger than our container... IF diSize > SIZEOF(_Data) THEN SET_Value := FALSE; END_IF // Here we should be ok, just set up the _DataType structure, and copy store the data IF SET_Value THEN THIS^._Descr.TypeClass := anyValue.TypeClass; // The typeclass is already filtered THIS^._Descr.diSize := diSize; // Set the (adjusted) size THIS^._Descr.pValue := ADR(_Data); // This will not change, just to be sure {IF defined (pou:SysMem.SysMemCpy)} SysMem.SysMemCpy(_DataType.pValue, anyValue.pValue, TO_UDINT(anyValue.diSize)); {ELSE} // An ugly replacement MemCpy FOR I:=0 TO diSize - 1 DO _Descr.pValue[I] := anyValue.pValue[i]; END_FOR {END_IF} // Otherwise, in case of failure maybe better set an empty value (overwrite the former data descriptor) ELSE THIS^._Descr.TypeClass := TYPE_CLASS.TYPE_NONE; THIS^._Descr.pValue := ADR(_Data); THIS^._Descr.diSize := 0; END_IF METHOD GET_Value : BOOL VAR_INPUT anyValue : ANY; END_VAR VAR I : DINT; END_VAR // We just have to serve the data, using the __System.AnyType structure received // Roughly we can say: IF anyValue.TypeClass = _Descr.TypeClass AND anyValue.pValue <> 0 // This should not be possible, already taken care of by Codesys (?) THEN {IF defined (pou:SysMem.SysMemCpy)} SysMem.SysMemCpy(anyValue.pValue, _DataType.pValue, TO_UDINT(MIN(anyValue.diSize, _Descr.diSize))); {ELSE} // An ugly replacement MemCpy FOR I:=0 TO MIN(anyValue.diSize -1, _Descr.diSize - 1) DO anyValue.pValue[I] := _Descr.pValue[I]; END_FOR {END_IF} // Just to make sure, that our string is terminated... IF anyValue.TypeClass = TYPE_CLASS.TYPE_STRING THEN anyValue.pValue[anyValue.diSize -1] := 0; END_IF GET_Value := TRUE; RETURN; END_IF // ... But can play more CASE anyValue.TypeClass OF TYPE_CLASS.TYPE_WSTRING : ; // Could do conversion TYPE_CLASS.TYPE_XSTRING : ; // Wow, I have to figure this out TYPE_CLASS.TYPE_PARAMS : ; // BTW, what is this, how to use? TYPE_CLASS.TYPE_ANYNUM : ; // ... END_CASE Be careful it was not tested. I'm sure can be done better, please feel free to comment 3. If you really want to do entries with variable size In a standard environment, it would be similar to the previous, except you dont have the container variable _Data, just use a pointer, practically _Descr.pValue At Initialize (SET_Value), you have to allocate the memory, would be easy with SysMem.SysMemAlloc - nowadays with SysMem.SysMemAllocData -, and you make sure to release it after use with SysMem.SysMemFreeData... SysMemAlloc was already hidden. The problem with this, that sooner or later your application will totally fragment the dynamic memory, and fail... So should look for some form of dynMaybe MemUtils.MemoryManager (I am not sure what is the status and the future of it). 4. You will end up by a LogEntry Factory ... 5. You could still have a look at this IEC Snippets BTW, Standard Codesys Logger is not a bad choice either. If you are really interested, I share some more code / library.
Last updated: 2025-03-09
Post by baltzer on ICertificateVerifier.VerifyCertificate doesn't appear to override an ERR_CERT_HAS_EXPIRED rejection in TCP_Client.Upgrade()
CODESYS Forge
talk
(Post)
Setup: Net Base Services (NBS), TCP_Client + TLSContext, ePurpose := CLIENT_SIDE, connecting to a third-party embedded device (Velux KLF200 home automation gateway) whose factory-installed TLS certificate expired on 2026-07-12 and has no user-facing renewal path. Tested on both CODESYS Control for Raspberry Pi SL (3.5.19.0) and CODESYS Control Win V3 x64, with identical results on both. Goal: Accept the peer's expired certificate via a custom ICertificateVerifier implementation, since the certificate itself can never be replaced. Implementation: FUNCTION_BLOCK FB_MyCertVerifier IMPLEMENTS NBS.ICertificateVerifier VAR udiCallCount : UDINT; aeCurStateLog : ARRAY[0..9] OF NBS.RTS_IEC_RESULT; END_VAR METHOD VerifyCertificate : UDINT VAR_INPUT hCert : NBS.RTS_IEC_HANDLE; eCurState : NBS.RTS_IEC_RESULT; END_VAR IF udiCallCount < 10 THEN aeCurStateLog[udiCallCount] := eCurState; END_IF udiCallCount := udiCallCount + 1; VerifyCertificate := 0; // also tried: VerifyCertificate := eCurState; Wired in via tlsContext.itfCertVerifer := certVerifier at declaration time, alongside itfTLSContext := tlsContext set at TCP_Client's own declaration (per an earlier forum thread here on ensuring inline start-values on FB-typed variables are actually honored when nested one level deep - that fix was needed and worked correctly for getting the handshake to start at all). Observed: - VerifyCertificate is confirmed called exactly once per connection attempt (via the call counter above). - eCurState passed in = 0x709 = ERR_CERT_HAS_EXPIRED - correctly reflecting the actual state of the peer's certificate. - Packet capture confirms the full TLS 1.2 handshake completes correctly at the wire level: ClientHello -> ServerHello -> Certificate -> ServerKeyExchange -> ServerHelloDone -> our ClientKeyExchange/ChangeCipherSpec/Finished -> server's ChangeCipherSpec/Finished. Both sides successfully complete the cryptographic handshake. - Despite this, TCP_Client.Upgrade() subsequently returns NBS.ERROR.CONNECTION_ERROR, and the connection is torn down with a plain TCP FIN (not a TLS alert) roughly 7-8ms after our side ACKs the server's Finished message. - TCP_Client.eErrorID (inherited from LCon) remains NO_ERROR throughout - the failure is only visible via Upgrade()'s return value. - Returning 0 (ERR_OK/ERR_CERT_OK - confirmed via the CmpErrors2 Interfaces documentation that these are literally the same value) makes no difference. - Echoing eCurState back unchanged (on the theory that this callback might work like mbedTLS's native verify callback, where the incoming state is a flags value to be cleared/modified and returned, rather than paired with a separate fixed "accept" sentinel) also makes no difference. - Identical result across udiVerificationMode := 0, 1, and 2. - Importing the peer's certificate into the runtime's trusted certificate store via cert-import trusted makes no difference either. - With itfCertVerifer left at its default (no custom verifier) and udiVerificationMode := 2, the underlying engine sends its own fatal TLS alert (handshake_failure) immediately after receiving the peer's Certificate message - suggesting built-in validation may reject at the record layer independent of whether a custom verifier is even present. Questions: 1. Is there an additional step required for a custom ICertificateVerifier to actually override an ERR_CERT_HAS_EXPIRED (or more generally, any ERR_CERT_*) rejection, or is certificate validation enforced unconditionally for a CLIENT_SIDE TLSContext regardless of what the verifier returns? 2. Is 0/ERR_OK genuinely the correct "accept" return value for VerifyCertificate, or does it expect something else (a specific bit pattern, a different constant, a value that must be computed from hCert itself)? 3. Is there a supported way to connect to a peer presenting a certificate that is both self-signed and expired, short of the peer issuing a new certificate? Happy to share the full packet captures or additional test combinations if useful. Also worth noting for anyone finding this thread later: a maintained Node-RED library for this same device (node-red-contrib-velux-klf200, forked to handle this exact expired-certificate situation) solves it by disabling built-in TLS validation entirely (rejectUnauthorized: false) and doing fingerprint-based pinning by hand after the handshake completes, rather than relying on a validation callback - which may be the more realistic approach here too if ICertificateVerifier genuinely can't override this class of rejection. Thanks in advance /JΓΈrgen Disclosure: most of the CODESYS code and this investigation was developed with the help of Claude (Anthropic's AI assistant) - the state machine design, SLIP/checksum implementation, and debugging methodology (including the packet capture analysis) were worked through in an extended back-and-forth with it. Posting here because we've run out of self-serviceable options and this now looks like it needs input from someone with visibility into NBS's actual implementation.
Last updated: 4 days ago
Post by pierre123 on User management - User Tab missing
CODESYS Forge
talk
(Post)
i had the same problem. Thanks you for the response.
Last updated: 2023-08-25
new feature: list/view plclogs from the plcs
CODESYS Forge
talk
(Thread)
new feature: list/view plclogs from the plcs
Last updated: 2023-08-30
Need help before losing control over myself with the BK1150 ;-)
CODESYS Forge
talk
(Thread)
Need help before losing control over myself with the BK1150 ;-)
Last updated: 2017-05-31
Compiling CoDeSys project using the command line interface
CODESYS Forge
talk
(Thread)
Compiling CoDeSys project using the command line interface
Last updated: 2021-01-27
How to control the Amp2 from HifiBerry ?
CODESYS Forge
talk
(Thread)
How to control the Amp2 from HifiBerry ?
Last updated: 2023-07-04
The required device description is not installed..
CODESYS Forge
talk
(Thread)
The required device description is not installed..
Last updated: 2023-10-03
Focus/Selection color frame around the element
CODESYS Forge
talk
(Thread)
Focus/Selection color frame around the element
Last updated: 2023-10-27
Post by mmoncada on Dinamically loading recipes
CODESYS Forge
talk
(Post)
I'm having trouble with the initial loading of recipes. I can create them and load one or the other, but when the program restarts the recipes are not listed. I'm calling: RecipeManCommands.ReloadRecipes and then RecipeManCommands.GetRecipeCount which returns 0 recipes. None of the methods returns error and if i call them again after RecipeManCommands.CreateRecipe RecipeManCommands.ReadAndSaveRecipe getRecipeCount returns the number of recipes created. When i restart the system, once again they are not listed even though the recipe files are there. Any ideas? Martin Btw, Codesys 3.5 SP 16 Path 9
Last updated: 2023-12-06
Using the Wago 750-658 CAN Gateway
CODESYS Forge
talk
(Thread)
Using the Wago 750-658 CAN Gateway
Last updated: 2024-07-23
No gateway with the given settings could be found
CODESYS Forge
talk
(Thread)
No gateway with the given settings could be found
Last updated: 2024-08-02
Get the .git folder path via scripting
CODESYS Forge
talk
(Thread)
Get the .git folder path via scripting
Last updated: 2024-08-08
How Could I Desactivated The Watchdog ?
CODESYS Forge
talk
(Thread)
How Could I Desactivated The Watchdog ?
Last updated: 2024-08-13
Post by remoyang on Package manager
CODESYS Forge
talk
(Post)
Also during the installation, it has the following error as attached
Last updated: 2024-08-16
Disable Communications to 'Modbus_Server_COM_Port' from the logic
CODESYS Forge
talk
(Thread)
Disable Communications to 'Modbus_Server_COM_Port' from the logic
Last updated: 2024-08-30
Is the Realtek RTL8119I-CG ethernet controler on supported list?
CODESYS Forge
talk
(Thread)
Is the Realtek RTL8119I-CG ethernet controler on supported list?
Last updated: 2024-09-04
Is the Realtek RTL8119I-CG ethernet controler on supported list?
CODESYS Forge
talk
(Thread)
Is the Realtek RTL8119I-CG ethernet controler on supported list?
Last updated: 2024-09-04
Is the Realtek RTL8119I-CG ethernet controler on supported list?
CODESYS Forge
talk
(Thread)
Is the Realtek RTL8119I-CG ethernet controler on supported list?
Last updated: 2024-09-04
Post by jinlee on Camera Feed (CCTV)
CODESYS Forge
talk
(Post)
Hi, Thanks for the information. However, I can't download the associated project.
Last updated: 2024-09-12
Clarifications regarding the appropriate runtime system to use
CODESYS Forge
talk
(Thread)
Clarifications regarding the appropriate runtime system to use
Last updated: 2024-09-26
Error trying to activate the demo Git licence
CODESYS Forge
talk
(Thread)
Error trying to activate the demo Git licence
Last updated: 2024-10-11
To search for an exact phrase, put it in quotes. Example: "getting started docs"
To exclude a word or phrase, put a dash in front of it. Example: docs -help
To search on specific fields, use these field names instead of a general text search. You can group with AND or OR.