SerialPort | Serial Port Communication using Windows API | Wrapper library

 by   jjuiddong C++ Version: Current License: MIT

kandi X-RAY | SerialPort Summary

kandi X-RAY | SerialPort Summary

SerialPort is a C++ library typically used in Utilities, Wrapper applications. SerialPort has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

Serial Port Communication using Windows API.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              SerialPort has a low active ecosystem.
              It has 15 star(s) with 13 fork(s). There are 5 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              SerialPort has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of SerialPort is current.

            kandi-Quality Quality

              SerialPort has no bugs reported.

            kandi-Security Security

              SerialPort has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              SerialPort is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              SerialPort releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of SerialPort
            Get all kandi verified functions for this library.

            SerialPort Key Features

            No Key Features are available at this moment for SerialPort.

            SerialPort Examples and Code Snippets

            No Code Snippets are available at this moment for SerialPort.

            Community Discussions

            QUESTION

            Windows Api, COM port: transmit data after receiving
            Asked 2021-Jun-14 at 07:22

            I have a microcontroller which I communicate with my windows pc, through FT232RL. On the computer side, I am making a C-library to send and receive data, using windows API.

            I have managed to:

            1. Receive data (or multiple receives),
            2. Transmit data (or multiple transmits),
            3. First transmit (or multiple transmits) and then receive data (or multiple receives)

            But I have not managed to:

            1. Transmit Data and then receive.

            If I receive anything, and then try to transmit, I get error. So, I guess when I receive data, there is a change in configuration of the HANDLE hComm, which I cannot find.

            So the question is, what changes to my HANDLE hComm configuration when I receive data, which does not allow me to transmit after that?

            Here is my code/functions and the main() that give me the error. If I run this, I get this "error 6" -screenshot of the error down below-:

            ...

            ANSWER

            Answered 2021-Jun-14 at 01:17

            According to MSDN:Sample, Maybe you need to set a pin's signal state to indicate the data has been sent/received in your microcontroller program. More details reside in your serial communication transmission of data standard. And you should write code according to the result of WaitCommEvent(hCom, &dwEvtMask, &o); like the linked sample.

            Source https://stackoverflow.com/questions/67903175

            QUESTION

            Send data received on serial port to JavaFX controller
            Asked 2021-Jun-05 at 07:11

            I'm trying to read data from the serial port and display it in a JavaFX controller. I'm using jSerialComm to read data from the serial port. This is their example:

            ...

            ANSWER

            Answered 2021-Jun-05 at 07:11

            It's not really clear what you're asking: you already have all the pieces.

            I'm not familiar with jSerialComm (in particular how it manages threading), but your JavaFX application will look like this:

            Source https://stackoverflow.com/questions/67838365

            QUESTION

            Cannot receive data from ORSSerialPort
            Asked 2021-May-31 at 22:11

            I'm trying to use ORSSerialPort to send and receive data to and from serial port.

            I'm following the example here but I'm using commandline app: https://github.com/armadsen/ORSSerialPort/tree/master/Examples/ORSSerialPortDemo

            I believe I copied/implemented every required method, but the problem is although I can send data to my serial port(I double confirmed from my serial port log and the send succeeded), I cannot receive anything.

            My code is very simple as below - it is only intended to be a prototype so the code might not be well designed.

            So am I missing anything that I cannot receive data from serial port? Any suggestions are appreciated.

            ...

            ANSWER

            Answered 2021-May-31 at 22:11

            Assuming the code you included is the complete program source code (ie. you're compiling it as a command-line app), the problem is that the program terminates right after sendString() is called, so the port has no chance to receive anything. You need to keep the program alive and running. There are multiple ways to do that, but the simplest is just to call RunLoop.main.run() as the last line of the program. That will cause the run loop to run indefinitely processing input from all sources, and will both keep the program alive and run the system machinery that ORSSerialPort relies on.

            Source https://stackoverflow.com/questions/67780446

            QUESTION

            Why does my app stop responding when navigating to MainPage twice when connecting to serial port?
            Asked 2021-May-28 at 08:59

            I am developing a simple UWP app which needs to listen to a serial port connected to an esp32 which has a rfid reader attached.

            It needs to receive UID of card, navigate to new page, and then navigate back to the original page after a timer has elapsed, or a button has been clicked.

            It is all working, except for the part where I navigate back to the original parent page. I believe it's because the app is trying to reconnect to the serial port, but it's unavailalbe. I've tested my theory by creating a setup button with the serial connection setup on this and it does work as expected.

            So, does Page_Loaded fire every time the page is reloaded? Is there a function which only fires on the first loading of the form? I can't get disposing of the serial port to work at all, i just get an unhandled exception. I don't have a problem leaving the serial port open though, but this seems to be causing problems too!

            Please see some sample code below:

            ...

            ANSWER

            Answered 2021-May-28 at 08:52

            So, does Page_Loaded fire every time the page is reloaded?

            Yes.

            Is there a function which only fires on the first loading of the form?

            You could use a boolean flag to determine whether to execute your method:

            Source https://stackoverflow.com/questions/67734374

            QUESTION

            C# - SerialPort.read() speed issue
            Asked 2021-May-20 at 19:17

            My code is designed to get data from a serial device and print its contents to a MS Forms Application. The IDE i use is Visual Studio 2019 - Community.

            The device does send a variable size packet. First i have to decode the packet "header" to get crucial information for further processing which is the first packet channel as well as the packet length.

            Since the packet does neither contain a line ending, nor a fixed character at the end, the functions SerialPort.ReadTo() and SerialPort.ReadLine() are not useful. Therefore only SerialPort.Read(buf,offset,count) can be used

            Since sending rather large packets (512bytes) does take time, I've implemented a function for calculation of a desired wait time, which is defined as (1000ms/baud-rate*(8*byte-count))+100ms

            While testing, I've experienced delay, much more than the desired wait times, so implemented a measure function for different parts of the function.

            In regular cases (with desired wait times) i except a log to console like this: Load Header(+122ms) Load Data (+326ms) Transform (+3ms)

            But its only like this for a few variable amount of records, usually 10, after that, the execution times are much worse:

            Load Header(+972ms) Load Data (+990ms) Transform (+2ms)

            Here you can see the complete function:

            ...

            ANSWER

            Answered 2021-May-20 at 19:17

            Instead of trying to figure out how long a message will take to arrive at the port, why not just read the data in a loop until you have it all? For example, read the header and calculate the msg size. Then read that number of bytes. Ex:

            Source https://stackoverflow.com/questions/67626023

            QUESTION

            I want to combine characters to make a string
            Asked 2021-May-11 at 09:16
            #include 
            #include "serialcomm.h"
            #include 
            #include 
            #define BUFF_SIZE 256
            
            int main()
            {
            
                CSerialComm serialComm;
            
                BYTE buff[BUFF_SIZE] = { 0, };
            
                int op = 0;
                int port = 0;
                int size = 0;
                int size2 = 0;
                int restart = 0;
                char port_s[20] = "";
                char send_string[1000];
                char confirm[BUFF_SIZE];
                char dec[BUFF_SIZE];
            
            
                printf("select mode(1. send, 2. receive) : ");
                scanf_s("%d", &op);
            
                printf("insert port num : ");
                scanf_s("%d", &port);
                getchar();
                if (op == 1) {
                    printf("plz submit data  (ex : 0x0a 0x01, 0x02, 0x0b) : ");
                    gets_s(send_string, sizeof(send_string));
                    size = serialComm.getHexData(send_string, buff);
            
                    printf("read size(max %d) : ", BUFF_SIZE);
                    scanf_s("%d", &size2);
                }
            
            
                sprintf_s(port_s, "COM%d", port);
            
                // STEP 1. SerialPort Connect
                if (!serialComm.connect(port_s)) {
                    printf("connect faliled");
                    return -1;
                }
                else {
                    printf("connect successed\n");
                }
            
                if (op == 1) {
                    // STEP 2. Send Command
            
                    while (1) {
            
            
            
                        if (!serialComm.sendCommand(buff, size)) {
                            printf("send command failed\n");
                        }
                        else {
                            int i = 0;
                            printf("tx data(%d) : [ ", size);
                            for (i = 0; i < size; i++) {
                                printf("0x%02X ", buff[i]);
                            }
                            printf("]\n");
                        }
                        Sleep(2000);
            
                        serialComm.readByte(buff, size2);
            
                        int j = 0;
                        printf("rx data(%d) : [ ", size2);
                        for (j = 0; j < size2; j++) {
                            printf("0x%02X ", buff[j]);
                        }
                        printf("]\n");
            
            
                        //data convert
                        char buffer[256];
                        int m = 0;
                        printf("[  ");
                        for (m = 0; m < size; m++) {
            
                            fprintf(stderr, "%d", buff[m]);
                            printf("  ");
                        }
                        printf("]\n");
            
                        sprintf_s(buffer, sizeof(buffer), "%d", buff[m]);
                        
                        char data1 = buff[0];
                        char data2 = buff[1];
                        char data3 = buff[2];
                        char data4 = buff[3];
                        char data5 = buff[4];
                        char data6 = buff[5];
                        char data7 = buff[6];
                        char data8 = buff[7];
                        char data1 = buff[8];
            
                        size = serialComm.getHexData(send_string, buff);
                        Sleep(2000);
                    }
            
            ...

            ANSWER

            Answered 2021-May-11 at 07:45

            UPDATE: As per cplusplus.com, perhaps a more reputable source, it looks like this is your best option:

            Source https://stackoverflow.com/questions/67482222

            QUESTION

            Weird things happen when I try to kill a Thread in java?
            Asked 2021-Apr-24 at 21:37

            I have this "Serial" class that extends Thread that works with a serial port. In the run() method I first open the port, set all the Serial params and add a SerialPortEventListener. Then i just put a while(go) where go is a private (so only the class can see it) boolean instance set as true. I have a kill method that not only it closes the port and remove the SerialEventListener, but also set "go" as false, hence the Thread should stop. Now, here is where things start getting weird: if I put a System.out.println(something) in the while(go), when I call the kill() method the Thred stops, but if I doesn't it remains alive. Do you have any ideas about why it works like that and how to solve it?

            ...

            ANSWER

            Answered 2021-Apr-24 at 20:11

            Unless go is declared volatile, there is no guarantee the while loop (or anything else) will read the current value.

            declare go as

            Source https://stackoverflow.com/questions/67246928

            QUESTION

            Why is the serial port component missing from my Visual Studio toolbox?
            Asked 2021-Apr-22 at 06:24

            serial port not seen in components

            I'm working on a windows form application but I can't find the needed SerialPort component in my toolbox. Tried resetting the toolbox but it didn't work either.

            Can anyone help me solve this issue?

            ...

            ANSWER

            Answered 2021-Apr-21 at 20:43

            The output tab of the Visual Studio on your screenshot, suggests that your project is a .NET Core project. To check this go to the project properties and check the Target Framework setting. SerialPort, you are expecting to see in the toolbox, is a component that is a part of the .NET framework which is different from the .NET Core

            If you want to keep using .NET Core as your platform try with the links below:

            https://docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport?view=dotnet-plat-ext-5.0&viewFallbackFrom=net-5.0

            https://www.nuget.org/packages/System.IO.Ports/

            Source https://stackoverflow.com/questions/67202747

            QUESTION

            using serial monitor as a button input for LibGDX game
            Asked 2021-Apr-21 at 17:40

            I'm currently working on a project that includes a short demo game, we've decided to use LibGDX as the java library and we're required to use an arduino and/or raspberry pi as a controller input. My assumption was to make an inputprocessor that uses the serial monitor input sent by the arduino. We're currently stumped on how to accomplish this and aren't even sure if you can use the inputprocessor in this way.

            ...

            ANSWER

            Answered 2021-Apr-21 at 17:40

            I would suggest moving your serial listener to a separate dedicated thread, which calls back to your game when it reads something.

            This way your GDX Game thread can continue to run as you expect, with a parallel thread listening for inputs, only notifying the game when it receives them.

            To achieve this, package your listener into a Runnable interface:

            Source https://stackoverflow.com/questions/67198183

            QUESTION

            Python Serial Readline() vs Readlines()
            Asked 2021-Apr-21 at 14:19

            I need to use some At commands & read the data for that I am using below cmds , the response I would be getting is in multiple lines

            ...

            ANSWER

            Answered 2021-Apr-21 at 14:18

            readline(): reads one line, if you use multiple times, each time it will keep giving next line until it reaches end of file or file is closed.

            readlines(): returns a list of lines from a file

            If you want the output of a whole file, you can use read() instead.

            About the timeout flag, I don't think timeout flag exists for I/O operations in Python? But if you are talking about the one in Serial, then it specifies the maximum time to wait for serial data.

            Source https://stackoverflow.com/questions/67196485

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install SerialPort

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/jjuiddong/SerialPort.git

          • CLI

            gh repo clone jjuiddong/SerialPort

          • sshUrl

            git@github.com:jjuiddong/SerialPort.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Wrapper Libraries

            jna

            by java-native-access

            node-serialport

            by serialport

            lunchy

            by eddiezane

            ReLinker

            by KeepSafe

            pyserial

            by pyserial

            Try Top Libraries by jjuiddong

            MapEditor

            by jjuiddongC++

            Camera-Streaming

            by jjuiddongC++

            Dx3D-Study

            by jjuiddongC++

            SerialPort-Monitor

            by jjuiddongC++