Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:15:11+00:00 2026-06-17T22:15:11+00:00

I am currently using the GraphView from the developer jjoe64 on GitGub and I

  • 0

I am currently using the GraphView from the developer jjoe64 on GitGub and I was wondering how I would retrieve the double I created in my BT connected thread class to the GraphView class. This is the original function to call random data, but I want the serial data from my BlueTooth class
The current function in this realtime graph is:

private double getRandom() {
    double high = 3;
    double low = 0.5;
    return Math.random() * (high - low) + low;
}

In my Bluetooth class, I have the command ConnectedThread.read(), but It’s not really working. Here it is:

public static double read() {
    try {
        byte[] buffer = new byte[1024];
        double bytes = mmInStream.read(buffer);
        return bytes;
    } catch(IOException e) {
        return 5;
    }
}

I am not sure if I it’s just my phone that’s too slow, it’s running Android2.3 (DesireHD), but my professor at my school said it should work fine if I just call ConnectedThread.read() and have it equal a double. Any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:15:11+00:00Added an answer on June 17, 2026 at 10:15 pm

    You haven’t provided enough information for a out-of-the box solution, but I’ll give it a shot anyway.

    First of all, I presume that mmInStream is an InputStream or its subclass. Look at the API of int InputStream.read(byte[] b):

    Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

    This means that what you’re returning from your read() method is just the number of bytes that have been written to the buffer from mmInStream. That is probably not what you want to do. What you probably want to do is read just the value from this stream. To do that you should:

    • wrap your mmInStream in a DataInputStream just after the mmInStream is created:

      mmInStream = yourMethodCreatingInputStream();
      dataInStream = new DataInputStream(mmInStream);
      
    • read the double value from the dataInStream. But as in all computer systems you must be aware of the exact format that your input value comes in. You must refer to the specification of the device you’re using to fetch the input data.

    Now the dataInStream comes in handy because it abstracts the necessary low-level IO operations and lets you focus on the data. It will automatically translate your queries for the data to the IO operations. For example:

    • If your data is in double format (and I believe that is the case according to the words of your professor), your read() method is as simple as:

      public static double read() {
          return dataInStream.readDouble();
      }
      
    • And in case the data is coming in the float format:

      public static double read() {
          return (double)dataInStream.readFloat();
      }
      

    But again, be sure to consult the specification of the device you’re using for the exact format. Some devices may pass you data in exotic formats like for example: “first 2 bytes are the integer part of the resulting value, second 2 bytes are the fractional part”. It is up to you as a consumer of the data to follow its format.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
iam currently using NSURLConnection class to hit my server and get some data from
Im currently using PHP to fetch results from a mysql db. Im also displaying
Im currently using CodeIgniters active record class to UPDATE a MySQL table. One of
I'm currently using the appearance proxy object for customising my application interface. I would
Currently using SQL Developer with no complaint, now there is a question about how
Currently using Google Analytics as a supplement to our paid tracking software, but neither
Currently using MySQL version 5.1.6 This is my first real world build and so
Currently using Xcode 4.2 and I have two view controllers (1 and 2). I
I currently using android NDK to write some native code in C. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.