Test and Measurement Forum

Linux: how to interpret data coming from enviromon?

Post general discussions on using our drivers to write your own software here

Linux: how to interpret data coming from enviromon?

Postby organtin » Fri Dec 08, 2006 1:19 pm

Hi. I'm trying to read data from an enviromon system connected to a humidiprobe sensor on a linux system. I tried to figure out how to get the data from the general documentation, that in fact, is quite poor.

I then wrote a function that reads the last data set as:
Code: Select all
typedef struct {
  SKT_HEADER header;
  unsigned char message [250];
} em_message;

void header(em_message *m, int sequence) {
  m->header.function = SF_FORWARD;
  m->header.sequence = sequence;
  m->header.timeout = 500;

int getLastValue(int channel, int s, int sequence, struct sockaddr_in *addr) {
  em_message m;
  if (verbose) {
    printf("(EXEC) getting last reading\n");
  header(&m, sequence);
  m.message[0] = 6; // the length of the message
  m.message[1] = EM_ADDR; // the enviromon address
  m.message[2] = LF_GET_BLOCK; //the function
  m.message[3] = LB_CURRENT; // function parameter (current reading)
  m.message[4] = 0; // unused
  m.message[5] = chksm(&m);
  execcmd(&m, s, addr);
  int data = (m.message[3+2*channel] << 8) + m.message[4+2*channel];
  return data;

Here execcmd is a function that "inject" the em_message structure on the s socket, as an UDP message.

I put sequence=0 (by the way, what is intended for?). Executing this function returns something like:

index: 0 value: 124
index: 1 value: 1
index: 2 value: 0
index: 3 value: 8
index: 4 value: 158
index: 5 value: 6
index: 6 value: 6
index: 7 value: 6
index: 8 value: 6
and so on, all other lines are equal to the last one, expect the last, who is:
index: 123 value: 247

As far as I understand: 124 in the 0-th component of the buffer is the length of the buffer (that in fact has 124 bytes). The following two values are the address of the sensor (1) and the function (0, I guess this is the return code, in fact). Then I interpret the data as follows: 8 and 158 should interpreted as 8*256+158, corresponding to the reading of channel 1 (the data returned by my function for channel=0; it seems to be the temperature), then what about the list of 6? What about the humidity?

Thank you.

Of course, if I can manage to read data correctly, I'll publish my source code, so anyone can use the system on linux (at least to read last data read).
Giovanni Organtini
Dip. di Fisica Universita' "La Sapienza"
P.le A. Moro 2 I-00185 ROMA
Posts: 1
Joined: Tue Nov 07, 2006 10:20 am
Location: Roma, Italy

Postby ziko » Thu Dec 28, 2006 2:01 pm

Hi and thank you for your post.

Currently we are running a limited service over the Christmas period and as such I cannot answer any programming questions. However we will be operating fully from next week.

Sorry for any inconvenience.

Kind regards

Technical Specialist
Zen Master
Zen Master
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Return to General Software Discussions

Who is online

Users browsing this forum: No registered users and 0 guests