<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Two libraries for COM port. Which is better to use?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/</id><updated>2021-03-11T08:59:18.179000Z</updated><subtitle>Recent posts to Two libraries for COM port. Which is better to use?</subtitle><entry><title>Two libraries for COM port. Which is better to use?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/?limit=25#7847" rel="alternate"/><published>2021-03-11T08:59:18.179000Z</published><updated>2021-03-11T08:59:18.179000Z</updated><author><name>spsschorsch</name><uri>https://forge.codesys.com/u/spsschorsch/</uri></author><id>https://forge.codesys.com285a1b3b8448cb09034558a419a2df643c389bd4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi mravlincek&lt;/p&gt;
&lt;p&gt;you're referring to exactly that library COMuser, which I need for changing an old plc project. But it is not installed with my CoDeSys.&lt;br/&gt;
As you said, it's tricky to find.&lt;br/&gt;
Do you know a source, where I could find it?&lt;br/&gt;
Or maybe you could provide me with it?&lt;br/&gt;
Sadly the original engineer who could provide is not available for me....&lt;/p&gt;
&lt;p&gt;Regards&lt;br/&gt;
Georg&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Two libraries for COM port. Which is better to use?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/?limit=25#e819" rel="alternate"/><published>2020-02-27T14:21:56.374000Z</published><updated>2020-02-27T14:21:56.374000Z</updated><author><name>mravlincek</name><uri>https://forge.codesys.com/u/mravlincek/</uri></author><id>https://forge.codesys.com78581505168b14a33878eec2eafc30e2538dd29d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;An update to any future similar problems. The connection is now working, but I have a problem with the data that is recieved. The device that is sending data to the PLC, sends a string of 80 ASCII characters, but what I recieve on my PLC is only the carriage return (and if set also line feed). I guess I need more information on how to correctly set the SysComRead, I'm guessing it's a problem of dwBufferAddress and dwBytesToRead.&lt;/p&gt;
&lt;p&gt;If anyone knows how to set these two parameters (or maybe it's something completely different) please let me know &lt;/p&gt;
&lt;p&gt;EDIT: I chose a completely different library that is a lot more user-friendly and it is very easy to use the RS232 ports. The library in question is &lt;strong&gt;COMuser&lt;/strong&gt;, it's a bit tricky to find online but if you know someone in automation, they can provide it to you.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Two libraries for COM port. Which is better to use?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/?limit=25#0452" rel="alternate"/><published>2020-02-27T14:21:55.980000Z</published><updated>2020-02-27T14:21:55.980000Z</updated><author><name>mravlincek</name><uri>https://forge.codesys.com/u/mravlincek/</uri></author><id>https://forge.codesys.com83160ac654c99ec2243407e3b09f7aae946c9560</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks for your reply. I had a feeling that this library would be better, but unfortunately the entire project is already created in Codesys V2. And as far as I can see, there is no SysComOpen2 library there  (I might be wrong?)&lt;/p&gt;
&lt;p&gt;EDIT: But still, it is strange that I always get an error (FFFFFFFF) by just opening port COM1 (or even any other port number).&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Two libraries for COM port. Which is better to use?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/?limit=25#1171" rel="alternate"/><published>2020-02-27T14:21:54.721000Z</published><updated>2020-02-27T14:21:54.721000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comb8b13717aa18639347da7e4c041b37e1d3a827fd</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; KevinR&lt;/p&gt;
&lt;p&gt;Hello mravlincek,&lt;/p&gt;
&lt;p&gt;you better use the SysComOpen2 function. It gives you the opportunity to use extended settings, for example ByteSize option.&lt;br/&gt;
To check if the ComPort is open, use the RTS Handle. (Invalid Handle = RTS_INVALID_HANDLE) &lt;/p&gt;
&lt;p&gt;Quick and dirty example: &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;VAR&lt;/span&gt; 
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt;  &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;dwcomhandle&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;SysCom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RTS_IEC_HANDLE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt;  &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;xState&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;NOT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;xState&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="nv"&gt;SysComOpen2&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;ComSettingsBasic&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;, &lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;ComSettingsAdvanced&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;, &lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="ss"&gt;))&lt;/span&gt;&lt;span class="c1"&gt;; // Call the Function SysComOpen2 Only once! &lt;/span&gt;
&lt;span class="k"&gt;ELSE&lt;/span&gt;
   &lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;dwcomhandle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;SYSTYPES&lt;/span&gt;.&lt;span class="nv"&gt;RTS_INVALID_HANDLE&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="nv"&gt;xState&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;FALSE&lt;/span&gt;&lt;span class="c1"&gt;; // still closed &lt;/span&gt;
&lt;span class="k"&gt;ELSE&lt;/span&gt;
   &lt;span class="nv"&gt;xState&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;; // open&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Best Regards,&lt;br/&gt;
Kevin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Two libraries for COM port. Which is better to use?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/?limit=25#9da0" rel="alternate"/><published>2020-02-27T14:21:54.285000Z</published><updated>2020-02-27T14:21:54.285000Z</updated><author><name>mravlincek</name><uri>https://forge.codesys.com/u/mravlincek/</uri></author><id>https://forge.codesys.com263f7476e5c81699df1fef59a8cbbdf41458691f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Update: OK so it seems I have figured out a few things myself. Mostly I have problems with me beeing used to V3 and trying to work with V2 Codesys &lt;/p&gt;
&lt;p&gt;So I have discovered a new problem. The SysComOpen always returns 0xFFFFFFFF no matter which port I try to open for my XVS440. The code is this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;opencomport&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;bread&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;opencomport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;TRUE&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="nv"&gt;dwcomhandle&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;SysComOpen&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;com1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;dwcomhandle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;#&lt;span class="nv"&gt;FFFFFFFF&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="nv"&gt;bcomportopened&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;and it always sets the bcomportopened to TRUE?   It seems that I am doing something wrong, or maybe the port isn't working? This is for RS232 right?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Two libraries for COM port. Which is better to use?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/?limit=25#aad5" rel="alternate"/><published>2020-02-27T14:21:53.896000Z</published><updated>2020-02-27T14:21:53.896000Z</updated><author><name>mravlincek</name><uri>https://forge.codesys.com/u/mravlincek/</uri></author><id>https://forge.codesys.com740ad857e7b41748cfb218d9974f5091c0849029</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;I'm trying to use the syslibcom library for the first time. I can sort of understand the general principle of how things work, but I am stuck at the very begging  I am using ST and I cannot get past this error: "Error 4012: PLC_PRG (2): Type mismatch in parameter 'ComSettings' of 'SYSCOMSETTINGS': Cannot convert 'ComSettings' to 'POINTER TO COMSETTINGS'.&lt;/p&gt;
&lt;p&gt;If someone would be so kind to write a simple example in ST of how to use this library to communicate via RS232 just to listen to the port and write the data that comes through.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Two libraries for COM port. Which is better to use?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/?limit=25#2261" rel="alternate"/><published>2020-02-27T14:21:52.736000Z</published><updated>2020-02-27T14:21:52.736000Z</updated><author><name>Strucc</name><uri>https://forge.codesys.com/u/strucc/</uri></author><id>https://forge.codesys.com536ea512d6a5d406621cd9fc1564999332eea140</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;A &lt;strong&gt;very subjective&lt;/strong&gt; answer:&lt;/p&gt;
&lt;p&gt;I prefer to use the "old" SysLibCom. Many reasons:&lt;br/&gt;
- I myself develop libraries, with different solutions for assyncronousity&lt;br/&gt;
- The way to provide parameters to CAA Serial library is really frustrating (you can't do that in the declaration part)&lt;br/&gt;
- I don't use any very special features of the com port, I mostly run with basic settings&lt;/p&gt;
&lt;p&gt;The reason to use CAA or more sophisticated libraries could be:&lt;br/&gt;
- Uniformity (standard behavior modell)&lt;br/&gt;
- Even more platform independency&lt;/p&gt;
&lt;p&gt;In my case I didn't see any advantage of those (once again, I'm developing libraries), but I had problems with the standard behavior model (for example executing multiple single byte read operation within one task cycle), so I returned to the "roots"&lt;/p&gt;
&lt;p&gt;What I'd really like to see from 3S is a total platform independent serial (and socket) communication library. What I mean here (it's mostly for sockets) is where the Open, Connect, etc... functions return the same results, and take the same parameters on each platforms. But, nothing else fancy added to them! If I'd like to go async, then I use select... etc. It's a more common, and more documented practice, than learning a new library, and guessing what is behind....&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Two libraries for COM port. Which is better to use?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/7b128d8afa/?limit=25#bb27" rel="alternate"/><published>2020-02-27T14:21:52.332000Z</published><updated>2020-02-27T14:21:52.332000Z</updated><author><name>chab</name><uri>https://forge.codesys.com/u/chab/</uri></author><id>https://forge.codesys.com5cb45dc0130728e97cc91969d33ceb4f56f59ca9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;For serial communication, via the COM port, several libraries are available: &lt;br/&gt;
- SysCom&lt;br/&gt;
- Serial Communication (includes CAA SerialCom)&lt;br/&gt;
Both libraries have APIs that are similar: open, close, read and write. SysCom has some more extra functions.&lt;/p&gt;
&lt;p&gt;Which library is the most suitable?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br/&gt;
Edwin.&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: ComPortLib_03.JPG" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=436"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>