Android-SerialPort-API | open source Android serial communication Demo and modify | Wrapper library

 by   licheedev Java Version: 2.1.3 License: Apache-2.0

kandi X-RAY | Android-SerialPort-API Summary

kandi X-RAY | Android-SerialPort-API Summary

Android-SerialPort-API is a Java library typically used in Utilities, Wrapper applications. Android-SerialPort-API has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. However Android-SerialPort-API has 3 bugs. You can download it from GitHub, Maven.

Fork from Google's open source Android serial communication Demo and modify it into an Android Studio project
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              Android-SerialPort-API has a medium active ecosystem.
              It has 1088 star(s) with 333 fork(s). There are 28 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 21 open issues and 24 have been closed. On average issues are closed in 91 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of Android-SerialPort-API is 2.1.3

            kandi-Quality Quality

              OutlinedDot
              Android-SerialPort-API has 3 bugs (1 blocker, 0 critical, 2 major, 0 minor) and 54 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 7 security hotspots that need review.

            kandi-License License

              Android-SerialPort-API is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              Android-SerialPort-API releases are available to install and integrate.
              Deployable package is available in Maven.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              Android-SerialPort-API saves you 379 person hours of effort in developing the same functionality from scratch.
              It has 902 lines of code, 44 functions and 23 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed Android-SerialPort-API and discovered the below as its top functions. This is intended to give you an instant insight into Android-SerialPort-API implemented functionality, and help decide if they suit your requirements.
            • Initialize View
            • Returns the input stream for this object
            • Returns the serial port
            • Creates the application
            • Display an error dialog
            • Returns the output stream to the output stream
            • Creates a new builder configured with the specified device and baudrate
            • Initializes the device preferences
            • Get a String array of all device names
            • Get the absolute path of all devices in the system
            • Returns a vector of the driver available on the terminal
            • This method is called when the client is destroyed
            • Closes the serial port
            • Close the serial port
            • Close the stream
            • Initialize the service
            • This method is called when data received from the client is received
            • Called when a byte is received
            • Initialize the view
            • Create the activity
            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

            In order to read/write to a serial port in Android you'll need su binary installed on device (this can be done by rooting the device). Usually Android devices that has the ability to communicate with serial ports have su installed on the default path "/system/bin/su". To change this use:.
            Check sample project
            https://juejin.im/post/5c010a19e51d456ac27b40fc

            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/licheedev/Android-SerialPort-API.git

          • CLI

            gh repo clone licheedev/Android-SerialPort-API

          • sshUrl

            git@github.com:licheedev/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

            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 licheedev

            Android-SerialPort-Tool

            by licheedevJava

            Modbus4Android

            by licheedevJava

            CommonSize

            by licheedevJava

            SerialWorker

            by licheedevJava