B4R Question InLine C and Dallas-Address

newbie

Member
Licensed User
Longtime User
Hi,

can someone tell me
how to transfer the dallas-device-address from inline-c
to a string-array defined in B4R ??????
I have try a lot but nothing work :-(


Thanks for any help
 

newbie

Member
Licensed User
Longtime User
Hi,

here is a part of the code,
in void getaddress i want to store the requested addresses in the main string-array
all what i have try give me a conversion error.
All other void works fine.

part of the code:
Private SolarAddress(10) As string  ' here i want to store the requested addresses


Sub Init
    Log("Init Dallas")
    RunNative("setup", Null)
End Sub


Sub GetAllTemp
    Log("Get Dallas Temp --------")
    
    RunNative("getcount", Null)
    RunNative("getaddress", Null)
    
    Log("Solar  SensorCount1: ",SensorCount1)
    For i= 0 To 9
        Log("      ",i,": ",SolarAddress(i))
    Next
    
    
    Log("Kamin  SensorCount2: ",SensorCount2)
    Log("Puffer SensorCount3: ",SensorCount3)
    Log("Haus   SensorCount4: ",SensorCount4)
    
    RunNative("gettemp", Null)
    
    Log("Kessel   : ",tKessel)
    Main.mData(4).Value = tKessel
    
    Log("Kessel R1: ",tKesselR1)
    Main.mData(5).Value = tKesselR1
    
    Log("Kessel R2: ",tKesselR2)
    Main.mData(6).Value = tKesselR2
    
    Log("Kessel R3: ",tKesselR3)
    Main.mData(30).Value = tKesselR3

  ......


#if C
// Include the libraries
#include <OneWire.h>
#include <DallasTemperature.h>

// Setup a oneWire instance to communicate with any OneWire devices
    OneWire oneWire1(32);
    OneWire oneWire2(33);
    OneWire oneWire3(14);
    OneWire oneWire4(15);

// Pass oneWire reference to Dallas Temperature.
    DallasTemperature SensorHaus  (&oneWire1);
    DallasTemperature SensorKamin (&oneWire2);
    DallasTemperature SensorSolar (&oneWire3);
    DallasTemperature SensorPuffer(&oneWire4);
    
DeviceAddress DevAddress [10];

void setup (B4R::Object* unused) {
// Start up the library.
    SensorSolar.begin();
}

void getcount (B4R::Object* unused) {
    
  SensorSolar.begin();
  b4r_dallas::_sensorcount1 = count;
      
  SensorKamin.begin();
  b4r_dallas::_sensorcount2 = SensorKamin.getDeviceCount();
    
  SensorPuffer.begin();
  b4r_dallas::_sensorcount3 = SensorPuffer.getDeviceCount();
    
  SensorHaus.begin();
  b4r_dallas::_sensorcount4 = SensorHaus.getDeviceCount();
}

void getaddress (B4R::Object* o) {
    int x = 0;
    int count = 0;
    
    count = SensorSolar.getDeviceCount();

    for (int x = 0; x < count; x++) {
        // Read its address
        SensorSolar.getAddress(DevAddress[x], x);
    }
    
    for (x = 0; x < count; x++) 
      {
    
         // Don't work     
         //((byte*)b4r_dallas::_solaraddress->data)[x]=String(DevAddress[x], HEX);
    
         // Don't work       
         //((byte*)b4r_dallas::_solaraddress->data)[x]=DevAddress[x];

         // ???? How to ????
   }
}


void gettemp (B4R::Object* unused) {
//    Request temperature readings from ALL devices on the bus
    
    SensorSolar.requestTemperatures();
    delay(1000);
    b4r_dallas::_tsolarpo = SensorSolar.getTempC(adrSolarPO);   



SensorKamin.requestTemperatures();
delay(1000);
SensorPuffer.requestTemperatures();
delay(1000);
SensorHaus.requestTemperatures();
delay(1000);
}

#End if
 
Upvote 0
Top