android-serialport-api | Accessing serial ports for Android

 by   cepr C Version: android-serialport-api-1.1 License: No License

kandi X-RAY | android-serialport-api Summary

kandi X-RAY | android-serialport-api Summary

android-serialport-api is a C library.,roid-serialport-api has no bugs, it has no vulnerabilities and it has medium support. You can download it from GitHub.

Accessing serial ports for Android
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              android-serialport-api has a medium active ecosystem.
              It has 1176 star(s) with 514 fork(s). There are 38 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 9 open issues and 1 have been closed. On average issues are closed in 131 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of android-serialport-api is android-serialport-api-1.1

            kandi-Quality Quality

              android-serialport-api has 0 bugs and 0 code smells.

            kandi-Security Security

              android-serialport-api has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              android-serialport-api code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              android-serialport-api does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              android-serialport-api releases are not available. You will need to build from source code and install.
              It has 1221 lines of code, 48 functions and 23 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            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 android-serialport-api
            Get all kandi verified functions for this library.

            android-serialport-api Key Features

            No Key Features are available at this moment for android-serialport-api.

            android-serialport-api Examples and Code Snippets

            No Code Snippets are available at this moment for android-serialport-api.

            Community Discussions

            Trending Discussions on android-serialport-api

            QUESTION

            Java close FileInputStream before reading anything
            Asked 2017-Apr-07 at 09:17

            I have a very peculiar problem. In android I am using FileInputStream to read from the serial (ttySx/COM) port. I am using this to decide which of the known devices is connected (if any at all). What I basically do is:

            1. Are you device 1? No...
            2. Are you device 2? No...
            3. Are you device 3? Yes...
            4. Great lets do some stuff...

            And this works great. If there is any incoming data to read (response from device), everything is fine. However, if there is no device connected to ttySx there is nothing to respond to my write. That means nothing to read.

            Now, FileInputStream.read() is a blocking call. When I call it in the thread, thread is effectively frozen. I cannot interrupt the thread because for that I would have to read something first. So far everything makes perfect sense.

            As there is no response from the port for quite some time I decide that there is nothing connected and want to stop reading and dispose of the thread(actually I do not want to bother with the port anymore because with nothing connected, it is useless to me at this moment). As mentioned earlier interrupt itself is no good. What should be working, is to close() the FileInputStream (read() will throw an exception and hooray!). The close() works... As long as the read() read anything ever (like when I had an answering device connected, then disconnect it -> read() is stuck - because no data to read - but close() works).

            However if there was not a thing connected to the port when the read() started (equals: I haven't read a single byte), the close() method does nothing. It does not close the stream. Nor does work the closing of FileInputStream channel.

            I could create a workarround: Store the FileInputStream somewhere and when I want to read from the port again later, use the same instance. That would work for me. Unfortunately I would quite unnecessarily block the port itself. No other process (for example another application) could read from the port because it is stuck in "uninterruptable" read...

            Any ideas why this is happening and how to make it right? Or some other way to detect if there is anything connected to the ttySx port?

            Thanks.

            EDIT1: The library used for communication with serial port is https://github.com/cepr/android-serialport-api

            ...

            ANSWER

            Answered 2017-Apr-07 at 09:17

            In the end we used FileInputStream::available().

            First time we tried it, it was like:

            1. Check if anything is available.
            2. Read (regardless of availability)

            Of course, when we checked the available, there was nothing to read yet. Then the read call blocked and waited for input. When we checked again, there was nothing available already, because read had cleared the port.

            Therefore this suggestion Java close FileInputStream before reading anything from M. Prokhorov was the correct one for my situation.

            If anyone would wonder about the behavior in question: From researching it, it seems that reading streams was not designed for ports/sockets in first place. It was designed for regular files. You read, reach the end of document and close the stream. The exceptions are designed for wrong sequential usage of a stream (you open it, close id and then try to read). If you enter blocking mode, it will block until it reads at least a byte. No way around it. Close initializes the "closing state" similarly to setting the interrupt state of a thread.

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

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

            Vulnerabilities

            No vulnerabilities reported

            Install android-serialport-api

            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/cepr/android-serialport-api.git

          • CLI

            gh repo clone cepr/android-serialport-api

          • sshUrl

            git@github.com:cepr/android-serialport-api.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