Exemple #1
0
int main(int argc, const char **argv)
{
  SerialPortalIndication indication(IfcNames_SerialPortalIndicationH2S);
  EchoRequest echo(IfcNames_EchoRequestH2S);
  Simple simple(IfcNames_SimpleRequestH2S);

  SerialPortalRequestProxy *device = new SerialPortalRequestProxy(IfcNames_SerialPortalRequestS2H);
  EchoIndicationProxy *echoIndication = new EchoIndicationProxy(IfcNames_EchoIndicationS2H);
  SimpleRequestProxy *simpleRequest = new SimpleRequestProxy(IfcNames_SimpleRequestS2H);

  if (!argv[1]) {
      //realpath("/sys/class/tty/ttyUSB0/device/driver/");
      fprintf(stderr, "usage: %s /dev/ttyUSBn\n", argv[0]);
      return -EINVAL;
  }

  int serial_fd = initSerial(argv[1]);
  PortalSharedParam paramSerial;
  paramSerial.serial.serial_fd = serial_fd;

  Portal *mcommon = new Portal(0, 0, sizeof(uint32_t), portal_serialmux_handler, NULL, &transportSerial, &paramSerial, 0);
  PortalMuxParam param = {};
  param.pint = &mcommon->pint;

  EchoRequestProxy   echoSerial(0, &transportSerialMux, &param);
  SimpleRequestProxy simpleSerial(1, &transportSerialMux, &param);

  EchoIndication serialEchoIndication(0, &transportSerialMux, &param);
  Simple         serialSimple(1, &transportSerialMux, &param);

  device->setDivisor(134);
  sleep(2);

  echoSerial.say(0x6789);
  echoSerial.say2(0x22, 0x23);

  sleep(2);
  simpleSerial.say1(v1a);
  simpleSerial.say2(v2a, v2b);

  sleep(2);
  echoIndication->heard2(0x68,0x47);
  echoIndication->heard(0x22);

  sleep(2);
  simpleRequest->say1(19);

  while (1) {
    // wait
  }
}
Exemple #2
0
void loop()
{
  sen1.requestTemperatures();
  sen2.requestTemperatures();
  sen3.requestTemperatures();
  sen4.requestTemperatures();
  sen5.requestTemperatures();
  
  echoSerial();
  delay(1000);
  echoSerial();
  delay(1000);
    
  digitalWrite ( BACKLIGHT_PIN, HIGH );
  
  if(sen1.getTempCByIndex(0) < 80){
    tmp1=sen1.getTempCByIndex(0);
  }
  if(sen2.getTempCByIndex(0) < 80){
    tmp2=sen2.getTempCByIndex(0);
  }
  if(sen3.getTempCByIndex(0) < 80){
    tmp3=sen3.getTempCByIndex(0);
  }
  if(sen4.getTempCByIndex(0) < 80){
    tmp4=sen4.getTempCByIndex(0);
  }
  if(sen5.getTempCByIndex(0) < 80){
    tmp5=sen5.getTempCByIndex(0);
  }
  
   lcd.home ();                   // go home
  lcd.print("T1=");  
  lcd.print(tmp1);
  lcd.print(" T2=");
  lcd.print(tmp2);
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print("T3=");
  lcd.print(tmp3);
  lcd.print("  T4=");
  lcd.print(tmp4);
  
  Serial.print(tmp1);
  Serial.print("|");
  Serial.print(tmp2);
  Serial.print("|");
  Serial.print(tmp3);
  Serial.print("|");
  Serial.print(tmp4);
  Serial.print("|");
  Serial.print(tmp5);
  Serial.println(";");
 
  for(int i=0;i<5;i++){
    echoSerial();
    delay(1000);
  }
 
 digitalWrite ( BACKLIGHT_PIN, LOW );
  
}