Пример #1
0
PeriodRange* NetAIOPeriodRangeList(NetAIO *ob) {
  Stream *out = ob->out;
  int ret_len;
  PeriodRange* ret;
  WriteInt16LE(ob->out,0x0009);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x06);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0009) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x06) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x71) longjmp(ob->conn->exception,3);
  ret_len = ReadInt32LE(ob->in);
  ret = ArrayAlloc(ret_len,12);
  {
    int i;
    for(i=0;i<ret_len;i++) {
      if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
      ret[i].start = ReadUInt32LE(out);
      if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
      ret[i].step = ReadUInt32LE(out);
      if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
      ret[i].count = ReadUInt32LE(out);
    }
  }
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
Пример #2
0
CANResult NetCANRxMulti(NetCAN *ob,CANMessage* msg,int32 min) {
  Stream *out = ob->out;
  int ret_len;
  CANResult ret;
  WriteInt16LE(ob->out,0x0007);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x05);
  WriteInt32LE(ob->out,ArrayLength(msg));
  WriteInt32LE(ob->out,min);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0007) longjmp(ob->conn->exception,1);
  if (ReadInt8LE(ob->in) != 0x05) longjmp(ob->conn->exception,2);
  if (ReadInt8LE(ob->in) != 0xCB) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadInt8LE(ob->in) != 0x74) longjmp(ob->conn->exception,3);
  if (ReadInt32LE(ob->in)!=ArrayLength(msg)) longjmp(ob->conn->exception,5);
  {
    int i;
    for(i=0;i<ArrayLength(msg);i++) {
      if (ReadInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
      msg[i].flags = ReadUInt32LE(out);
      if (ReadInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
      msg[i].id = ReadUInt32LE(out);
      if (ReadInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
      msg[i].t_sec = ReadUInt32LE(out);
      if (ReadInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
      msg[i].t_usec = ReadUInt32LE(out);
      if (ReadInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
      msg[i].length = ReadUInt32LE(out);
      if (ReadInt8LE(ob->in) != 0x40) longjmp(ob->conn->exception,3);
      ReadInt32LE(out);
      {
        int k;
        for(k=0;k<8;k++) {
          msg[i].data[i] = ReadUInt8LE(out);
        }
      }
    }
  }
  if (ReadInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
Пример #3
0
uint32 NetBusAssign32X(NetBus *ob,int32 Address,int32 BitMSB,int32 BitLSB,int32 Value) {
  Stream *out = ob->out;
  int ret_len;
  uint32 ret;
  WriteInt16LE(ob->out,0x0001);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x1E);
  WriteInt32LE(ob->out,Address);
  WriteInt32LE(ob->out,BitMSB);
  WriteInt32LE(ob->out,BitLSB);
  WriteInt32LE(ob->out,Value);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0001) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x1E) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
  ret = ReadUInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
Пример #4
0
real32 ReadReal32LE(Stream *st) {
  union {
    real32 ret;
    uint32 ret0;
  } u;
  u.ret0 = ReadUInt32LE(st);
  return u.ret;
}
Пример #5
0
int32 NetEDIOQueryPWMfd(NetEDIO *ob,int32 num,uint32 freq[1],uint32 DC[1]) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x000A);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x07);
  WriteInt32LE(ob->out,num);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x000A) longjmp(ob->conn->exception,1);
  if (ReadInt8LE(ob->in) != 0x07) longjmp(ob->conn->exception,2);
  if (ReadInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadInt8LE(ob->in) != 0x43) longjmp(ob->conn->exception,3);
  ReadInt32LE(out);
  {
    int i;
    for(i=0;i<1;i++) {
      freq[i] = ReadUInt32LE(out);
    }
  }
  if (ReadInt8LE(ob->in) != 0x43) longjmp(ob->conn->exception,3);
  ReadInt32LE(out);
  {
    int i;
    for(i=0;i<1;i++) {
      DC[i] = ReadUInt32LE(out);
    }
  }
  if (ReadInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
Пример #6
0
uint32 NetDIOCount(NetDIO *ob) {
  Stream *out = ob->out;
  int ret_len;
  uint32 ret;
  WriteInt16LE(ob->out,0x0005);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x0A);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0005) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x0A) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
  ret = ReadUInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
Пример #7
0
uint32 NetBusPeek32(NetBus *ob,int32 Address) {
  Stream *out = ob->out;
  int ret_len;
  uint32 ret;
  WriteInt16LE(ob->out,0x0001);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x07);
  WriteInt32LE(ob->out,Address);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0001) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x07) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
  ret = ReadUInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
Пример #8
0
uint32 NetCANBaudSet(NetCAN *ob,uint32 opt_baud) {
  Stream *out = ob->out;
  int ret_len;
  uint32 ret;
  WriteInt16LE(ob->out,0x0007);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x02);
  WriteUInt32LE(ob->out,opt_baud);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0007) longjmp(ob->conn->exception,1);
  if (ReadInt8LE(ob->in) != 0x02) longjmp(ob->conn->exception,2);
  if (ReadInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
  ret = ReadUInt32LE(out);
  if (ReadInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
Пример #9
0
uint32 NetAIOChannelSamplePeriod(NetAIO *ob,int32 ch,uint32 ns) {
  Stream *out = ob->out;
  int ret_len;
  uint32 ret;
  WriteInt16LE(ob->out,0x0009);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x0B);
  WriteInt32LE(ob->out,ch);
  WriteUInt32LE(ob->out,ns);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0009) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x0B) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
  ret = ReadUInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
}