Total members 11893 |It is currently Wed Nov 13, 2024 1:21 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka



Go to page Previous  1, 2, 3, 4  Next


DS75.java:53: non-static variable t cannot be referenced from a static context
t= recevoirOctets(2);
^
DS75.java:53: non-static method recevoirOctets(int) cannot be referenced from a
static context
t= recevoirOctets(2);
^
DS75.java:53: incompatible types
found : int[]
required: int
t= recevoirOctets(2);
^
3 errors




Author:
Newbie
User avatar Posts: 37
Have thanks: 0 time

The integer "int t" is defined inside the class and called in the main function .You can't do that.If you want to do that you have to create and object from the class and then call the integer "t" from that object.Or you can create and integer "t" inside the main function that will be different from the one inside the class.and also the function recevoirOctets(int) and there are other thing
recevoirOctets(int) function return array of int[] not just int.

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

What is wrong now?

Code:
public class DS75 extends I2cTerminal {
double d;
int t;

  public DS75(I2cDriver driver, int adr){
    super(driver, adr);
  }

  public double getTemp(){

    int [] t = new int[2];
    try {
      t= recevoirOctets(2);
    } catch (Exception e) {
        e.printStackTrace();
      }
    //t = recevoirOctets(2);
    t[0]=1;
    //t[0]=!t[0]; // 0xFF-t[0];
    //t[1];

    try {
       t = envoyerEtRecevoirOctet(0);
    } catch (Exception e) {
        e.printStackTrace();
      }

    // beginning 9

    d=t[0];
    if (t[1]!=0)
      d=d+0.5;

    // end of 9

    // beginning 10

    d = t[0];
    d=d+((t[1]&0xA0)/64)*0.25;

    // end of 10

    // beginning 11

    d=t[0];
    d=d+((t[1]&0xB0)/64)*0.125;

    // end of 11

    // beginning 12

    d=t[0];
    d=d+((t[1]&0xC0)/64)*0.0625;

    // end of 12

    return d;
  }

  public static void main(String[] args){
    try {
      DS75 ds75 = new DS75(new I2cDriver(new I2cHardware("COM1")), 0x90);
      System.out.println(ds75.getTemp());
    } catch (Exception e) {
        e.printStackTrace();
      }

  }
}


Error
E:\src\projektui\std>java DS75
Exception in thread "main" java.lang.NoClassDefFoundError: javax/comm/PortInUseException
at DS75.main(DS75.java:62)



Author:
Newbie
User avatar Posts: 37
Have thanks: 0 time

Quote:
import javax.comm.*;


Do you have this package "javax.comm.*;

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

in this computer no


Author:
Newbie
User avatar Posts: 37
Have thanks: 0 time

These classes need this package to run.I can't compile it without this package.

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

i understand i tried that at home and program showing

F:\src\projektui\std>java DS75
starting I2cHardware...
****COM1
driver i2c initialised on COM1


and nothing else. what you advice to do?

he have to show something more


Author:
Newbie
User avatar Posts: 37
Have thanks: 0 time

Hello,
Does anybody know how to update array with new values?

I have array
private double[] temparray = new double[]{70.05d, 10.20d, 25.00d, 50.53d, 40.60d, 100.00d};

and want to update it with new values which give computer. time interval 10min, after 10 min should be added one more value and etc


Author:
Newbie
User avatar Posts: 37
Have thanks: 0 time

you use arrayname[index]
for example :
Code:
temparray[0]=12.2d;


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

but how during different time


Author:
Newbie
User avatar Posts: 37
Have thanks: 0 time
Post new topic Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3, 4  Next










Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com