Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Re: DALLAS DS75 help

Fri Jun 22, 2007 4:43 pm

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



Re: DALLAS DS75 help

Fri Jun 22, 2007 4:56 pm

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.

Re: DALLAS DS75 help

Mon Jun 25, 2007 9:39 am

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)


Re: DALLAS DS75 help

Mon Jun 25, 2007 4:48 pm

import javax.comm.*;


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

Re: DALLAS DS75 help

Mon Jun 25, 2007 4:53 pm

in this computer no

Re: DALLAS DS75 help

Mon Jun 25, 2007 4:58 pm

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

Re: DALLAS DS75 help

Mon Jun 25, 2007 5:04 pm

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

Re: DALLAS DS75 help

Tue Jun 26, 2007 2:17 pm

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

Re: DALLAS DS75 help

Tue Jun 26, 2007 4:14 pm

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


Re: DALLAS DS75 help

Tue Jun 26, 2007 4:51 pm

but how during different time

Post a reply