Serial port controller - how to initialize device

Hi,

I want to read data from an rfxcom receiver, which is a multi-device 433 mhz wireless receiver (it can transmit too, but I want to start with receiving). I understand how I can make a serial port device and add a register variable (I do this already to read data from my utility meter). Now, before starting to receive data from this device, I need to initialize it by sending it some specific commands and checking for the ‚ready to receive‘ reply. My question is where I should do this. Is there a ‚on startup‘ event or something like this, or should I hack my way around it by setting a timer that goes off every 10 seconds or so, checks a boolean variable ‚is initialized‘, and if not, does the init? It’s easy to see that this is a hackish approach, which is why I’m asking if there’s a better way. Thanks.

cheers,

roel

Please check out the logical treeview -> core instances -> events.

This special module provides you the possibility to set a startup script, which is the perfect location for initialization.

paresy

hello

i’m using the rfxcom receiver,433 mhz

example from my temperatur sensor

<?



SetValueString(22195 /*[FTDI\Auswertung FTDI\RX]*/ ,$IPS_VALUE );

//Daten als dez-String auslesen
$instr=GetValueString(22195 /*[FTDI\Auswertung FTDI\RX]*/  );
$datenstr="";
$laenge = strlen ($instr );

SetValueString(44475 /*[FTDI\Auswertung FTDI\Daten]*/  ,$instr);


//echo "$laenge
";
//echo "$instr
";


for($i=0; $i<strlen($instr); $i++)
 {
 $datenstr.=strtoupper(ord($instr{$i}))." ";
  }
  
  
$Byte="";
$Byte = explode(" ",$datenstr);

//echo "$Byte[0]
";
//echo "$Byte[1]
";
//echo "$Byte[2]
";
//echo "$Byte[3]
";
//echo "$Byte[4]
";
//echo "$Byte[5]
";
//echo "$Byte[6]
";
//echo "$Byte[7]
";
//echo "$Byte[8]
";



if ((($Byte[0] == 8) and ($Byte[2] == 1) and ( $laenge ==9 )))
{

      $a = $Byte[6];
      $b = $Byte[7];
      $c = dechex($a);
      $d = dechex($b);


      $h = $c . $d;
       //var_dump($h);
		$f = hexdec($h);
		$Att = $f /10 ;

      SetValue(17802 /*[433 MHZ Temperatur 1]*/ , $Att );
}


best regards
jens

Thanks, that looks like the right place to initialize it.

Jens I see you use another module than I did - I’m using a serial port and a register variable. I guess the result should be the same though. Thanks for your suggestion.

I have one ‚problem‘, and that is that something (must be symcon itself?) seems to send some data to the serial port every 10 seconds or so. It’s always the same bytes - 01 03 00 20 DC . It doesn’t really do harm, but the RFXcom responds with some data so I had to make my script a lot more error-resistant than it would have been if only ‚real‘ messages came through.

I do have a ‚complaint‘ about the manual - the RegisterVariable suggests that one can/should do all communication with a com port through a register variable, but in my experience you can only receive data with it, and only in a ‚receiving‘ script write data back. The only way I could get the initialization to work, is through using SPRT_SendText() directly. A function that isn’t documented from what I could find, and which is reference on the RegisterVariable documentation page by its old name, COMPort_SendText(). I wasted a lot of time before I had that part figured out…