コード例 #1
0
ファイル: NetAIO.c プロジェクト: embeddedarm/libtsctl
int32* NetAIOTriggerList(NetAIO *ob) {
  Stream *out = ob->out;
  int ret_len;
  int32* ret;
  WriteInt16LE(ob->out,0x0009);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x07);
  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) != 0x07) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x53) longjmp(ob->conn->exception,3);
  ret_len = ReadInt32LE(ob->in);
  ret = ArrayAlloc(ret_len,4);
  {
    int i;
    for(i=0;i<ret_len;i++) {
      ret[i] = ReadInt32LE(out);
    }
  }
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #2
0
ファイル: NetDIO.c プロジェクト: embeddedarm/libtsctl
int32 NetDIOGetMulti(NetDIO *ob,int8* state,int32 offset) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x0005);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x0C);
  WriteInt32LE(ob->out,ArrayLength(state));
  WriteInt32LE(ob->out,offset);
  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) != 0x0C) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x50) longjmp(ob->conn->exception,3);
  if (ReadInt32LE(ob->in)!=ArrayLength(state)) longjmp(ob->conn->exception,5);
  {
    int i;
    for(i=0;i<ArrayLength(state);i++) {
      state[i] = ReadInt8LE(out);
    }
  }
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #3
0
ファイル: NetEDIO.c プロジェクト: coherentsolutions/libtsctl
int32* NetEDIOQueryFunction(NetEDIO *ob,EDIOType type) {
  Stream *out = ob->out;
  int ret_len;
  int32* ret;
  WriteInt16LE(ob->out,0x000A);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x03);
  WriteInt32LE(ob->out,type);
  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) != 0x03) longjmp(ob->conn->exception,2);
  if (ReadInt8LE(ob->in) != 0x53) longjmp(ob->conn->exception,3);
  ret_len = ReadInt32LE(ob->in);
  ret = ArrayAlloc(ret_len,4);
  {
    int i;
    for(i=0;i<ret_len;i++) {
      ret[i] = ReadInt32LE(out);
    }
  }
  if (ReadInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #4
0
ファイル: NetAIO.c プロジェクト: embeddedarm/libtsctl
int32 NetAIOReadys32(NetAIO *ob,const int32* buf) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x0009);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x1D);
  int i;
  WriteInt32LE(ob->out,ArrayLength(buf));
  for (i=0;i<ArrayLength(buf);i++) {
    WriteInt32LE(ob->out,buf[i]);
  }
  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) != 0x1D) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #5
0
ファイル: NetBus.c プロジェクト: embeddedarm/libtsctl
void NetBusPeekStream(NetBus *ob,int32 address,int32 direction,int8* dest) {
  Stream *out = ob->out;
  int ret_len;
  WriteInt16LE(ob->out,0x0001);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x15);
  WriteInt32LE(ob->out,address);
  WriteInt32LE(ob->out,direction);
  WriteInt32LE(ob->out,ArrayLength(dest));
  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) != 0x15) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x50) longjmp(ob->conn->exception,3);
  if (ReadInt32LE(ob->in)!=ArrayLength(dest)) longjmp(ob->conn->exception,5);
  {
    int i;
    for(i=0;i<ArrayLength(dest);i++) {
      dest[i] = ReadInt8LE(out);
    }
  }
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
} 
コード例 #6
0
ファイル: NetCAN.c プロジェクト: coherentsolutions/libtsctl
CANResult NetCANTx(NetCAN *ob,uint32 flags,uint32 id,const int8* data) {
  Stream *out = ob->out;
  int ret_len;
  CANResult ret;
  WriteInt16LE(ob->out,0x0007);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x01);
  WriteUInt32LE(ob->out,flags);
  WriteUInt32LE(ob->out,id);
  int i;
  WriteInt32LE(ob->out,ArrayLength(data));
  for (i=0;i<ArrayLength(data);i++) {
    WriteInt8LE(ob->out,data[i]);
  }
  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) != 0x01) longjmp(ob->conn->exception,2);
  if (ReadInt8LE(ob->in) != 0xCB) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #7
0
ファイル: NetAIO.c プロジェクト: embeddedarm/libtsctl
int32 NetAIOGets16(NetAIO *ob,int16* buf) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x0009);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x16);
  WriteInt32LE(ob->out,ArrayLength(buf));
  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) != 0x16) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x51) longjmp(ob->conn->exception,3);
  if (ReadInt32LE(ob->in)!=ArrayLength(buf)) longjmp(ob->conn->exception,5);
  {
    int i;
    for(i=0;i<ArrayLength(buf);i++) {
      buf[i] = ReadInt16LE(out);
    }
  }
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #8
0
ファイル: NetAIO.c プロジェクト: embeddedarm/libtsctl
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;
} 
コード例 #9
0
ファイル: NetCAN.c プロジェクト: coherentsolutions/libtsctl
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;
} 
コード例 #10
0
ファイル: NetBus.c プロジェクト: embeddedarm/libtsctl
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;
} 
コード例 #11
0
ファイル: NetAIO.c プロジェクト: embeddedarm/libtsctl
int32 NetAIOConfigure(NetAIO *ob,const real32* low,const real32* high,const int32* prec,const int32* rate,const int32* trigger,int32 itrig) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x0009);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x10);
  int i;
  WriteInt32LE(ob->out,ArrayLength(low));
  for (i=0;i<ArrayLength(low);i++) {
    WriteReal32LE(ob->out,low[i]);
  }
  WriteInt32LE(ob->out,ArrayLength(high));
  for (i=0;i<ArrayLength(high);i++) {
    WriteReal32LE(ob->out,high[i]);
  }
  WriteInt32LE(ob->out,ArrayLength(prec));
  for (i=0;i<ArrayLength(prec);i++) {
    WriteInt32LE(ob->out,prec[i]);
  }
  WriteInt32LE(ob->out,ArrayLength(rate));
  for (i=0;i<ArrayLength(rate);i++) {
    WriteInt32LE(ob->out,rate[i]);
  }
  WriteInt32LE(ob->out,ArrayLength(trigger));
  for (i=0;i<ArrayLength(trigger);i++) {
    WriteInt32LE(ob->out,trigger[i]);
  }
  WriteInt32LE(ob->out,itrig);
  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) != 0x10) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #12
0
ファイル: NetEDIO.c プロジェクト: coherentsolutions/libtsctl
int32 NetEDIOPreempt(NetEDIO *ob) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x000A);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x02);
  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) != 0x02) longjmp(ob->conn->exception,2);
  if (ReadInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #13
0
ファイル: NetAIO.c プロジェクト: embeddedarm/libtsctl
AIOType NetAIOType(NetAIO *ob) {
  Stream *out = ob->out;
  int ret_len;
  AIOType ret;
  WriteInt16LE(ob->out,0x0009);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x03);
  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) != 0x03) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0xCD) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #14
0
ファイル: NetDIO.c プロジェクト: embeddedarm/libtsctl
DIOState NetDIOGetAsync(NetDIO *ob,int32 DIONum) {
  Stream *out = ob->out;
  int ret_len;
  DIOState ret;
  WriteInt16LE(ob->out,0x0005);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x08);
  WriteInt32LE(ob->out,DIONum);
  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) != 0x08) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0xC4) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #15
0
ファイル: NetAIO.c プロジェクト: embeddedarm/libtsctl
int32 NetAIOReady(NetAIO *ob,int32 channel) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x0009);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x14);
  WriteInt32LE(ob->out,channel);
  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) != 0x14) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #16
0
ファイル: NetDIO.c プロジェクト: embeddedarm/libtsctl
DIOCaps NetDIOCapabilities(NetDIO *ob,uint32 num) {
  Stream *out = ob->out;
  int ret_len;
  DIOCaps ret;
  WriteInt16LE(ob->out,0x0005);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x0B);
  WriteUInt32LE(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) != 0x0005) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x0B) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0xC5) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #17
0
ファイル: NetEDIO.c プロジェクト: coherentsolutions/libtsctl
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;
} 
コード例 #18
0
ファイル: NetBus.c プロジェクト: embeddedarm/libtsctl
int32 NetBusBitToggle32(NetBus *ob,int32 Address,int32 BitNumber) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x0001);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x1B);
  WriteInt32LE(ob->out,Address);
  WriteInt32LE(ob->out,BitNumber);
  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) != 0x1B) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #19
0
ファイル: NetEDIO.c プロジェクト: coherentsolutions/libtsctl
int32 NetEDIOUnlock(NetEDIO *ob,uint32 num,int32 flags) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x000A);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x01);
  WriteUInt32LE(ob->out,num);
  WriteInt32LE(ob->out,flags);
  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) != 0x01) longjmp(ob->conn->exception,2);
  if (ReadInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #20
0
ファイル: NetEDIO.c プロジェクト: coherentsolutions/libtsctl
int32 NetEDIOHBridge(NetEDIO *ob,int32 num,HBState state) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x000A);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x0B);
  WriteInt32LE(ob->out,num);
  WriteInt32LE(ob->out,state);
  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) != 0x0B) longjmp(ob->conn->exception,2);
  if (ReadInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #21
0
ファイル: NetDIO.c プロジェクト: embeddedarm/libtsctl
void NetDIOWait(NetDIO *ob,int32* match,int32 min,int32 max,const int32* nh,const int32* nl) {
  Stream *out = ob->out;
  int ret_len;
  WriteInt16LE(ob->out,0x0005);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x09);
  WriteInt32LE(ob->out,ArrayLength(match));
  WriteInt32LE(ob->out,min);
  WriteInt32LE(ob->out,max);
  int i;
  WriteInt32LE(ob->out,ArrayLength(nh));
  for (i=0;i<ArrayLength(nh);i++) {
    WriteInt32LE(ob->out,nh[i]);
  }
  WriteInt32LE(ob->out,ArrayLength(nl));
  for (i=0;i<ArrayLength(nl);i++) {
    WriteInt32LE(ob->out,nl[i]);
  }
  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) != 0x09) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x53) longjmp(ob->conn->exception,3);
  if (ReadInt32LE(ob->in)!=ArrayLength(match)) longjmp(ob->conn->exception,5);
  {
    int i;
    for(i=0;i<ArrayLength(match);i++) {
      match[i] = ReadInt32LE(out);
    }
  }
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
} 
コード例 #22
0
ファイル: NetEDIO.c プロジェクト: coherentsolutions/libtsctl
int32 NetEDIOPWM(NetEDIO *ob,int32 num,uint32 periodHigh,uint32 periodLow) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x000A);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x04);
  WriteInt32LE(ob->out,num);
  WriteUInt32LE(ob->out,periodHigh);
  WriteUInt32LE(ob->out,periodLow);
  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) != 0x04) longjmp(ob->conn->exception,2);
  if (ReadInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #23
0
ファイル: NetAIO.c プロジェクト: embeddedarm/libtsctl
int32 NetAIOChannelVoltageRange(NetAIO *ob,int32 ch,real32 low,real32 high) {
  Stream *out = ob->out;
  int ret_len;
  int32 ret;
  WriteInt16LE(ob->out,0x0009);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x0D);
  WriteInt32LE(ob->out,ch);
  WriteReal32LE(ob->out,low);
  WriteReal32LE(ob->out,high);
  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) != 0x0D) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x13) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #24
0
ファイル: NetCAN.c プロジェクト: coherentsolutions/libtsctl
uint32 NetCANBaudGet(NetCAN *ob) {
  Stream *out = ob->out;
  int ret_len;
  uint32 ret;
  WriteInt16LE(ob->out,0x0007);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x03);
  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) != 0x03) 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;
} 
コード例 #25
0
ファイル: NetBus.c プロジェクト: embeddedarm/libtsctl
uint16 NetBusPeek16(NetBus *ob,int32 Address) {
  Stream *out = ob->out;
  int ret_len;
  uint16 ret;
  WriteInt16LE(ob->out,0x0001);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x05);
  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) != 0x05) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x01) longjmp(ob->conn->exception,3);
  ret = ReadUInt16LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
} 
コード例 #26
0
ファイル: NetEDIO.c プロジェクト: coherentsolutions/libtsctl
uint32 NetEDIOEdgeCount(NetEDIO *ob,int32 num,int32 edge) {
  Stream *out = ob->out;
  int ret_len;
  uint32 ret;
  WriteInt16LE(ob->out,0x000A);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x09);
  WriteInt32LE(ob->out,num);
  WriteInt32LE(ob->out,edge);
  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) != 0x09) 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;
} 
コード例 #27
0
ファイル: NetAIO.c プロジェクト: embeddedarm/libtsctl
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;
} 
コード例 #28
0
ファイル: fmt_qmd3.c プロジェクト: cr88192/bgbtech_engine
LBXGL_QMDL *LBXGL_QuakeMD3_Load(char *name)
{
	char namebuf[65];
	LBXGL_QMDL *tmp;
	quake_qmdl_t *head;
	byte *skinbuf;
	float *vecbuf;
	quake_md3surf_t *surf;
	VFILE *fd;
	char *s, *t;
	int i, j, k, base;
	int w, h;

	fd=vffopen(name, "rb");
	if(!fd)return(NULL);

	printf("loading md3 %s\n", name);

	tmp=gctalloc("lbxgl_quakemdl_t", sizeof(LBXGL_QMDL));
	head=&tmp->head;

	head->ident=ReadInt32LE(fd);
	head->version=ReadInt32LE(fd);

	if(head->ident==QMD4_ID)
	{
		tmp->name=dystrdup(name);
		LBXGL_QuakeMD4_StageLoad(tmp, fd);
		return(tmp);
	}

	if(head->ident!=QMD3_ID)
	{
		printf("LBXGL_QuakeMD3_Load(%s): Invalid Ident\n", name);
		return(NULL);
	}
	if(head->version!=QMD3_VERSION)
	{
		printf("LBXGL_QuakeMD3_Load(%s): Invalid Version\n", name);
		return(NULL);
	}
	vfread(namebuf, 1, 64, fd);
	head->flags=ReadInt32LE(fd);

	head->num_frames=ReadInt32LE(fd);
	head->num_tags=ReadInt32LE(fd);
	head->num_surfaces=ReadInt32LE(fd);
	head->num_skins=ReadInt32LE(fd);

	head->ofs_frames=ReadInt32LE(fd);
	head->ofs_tags=ReadInt32LE(fd);
	head->ofs_surfaces=ReadInt32LE(fd);
	head->ofs_end=ReadInt32LE(fd);

	tmp->tags=gcalloc(12*head->num_tags*sizeof(float));
	tmp->tagnames=gcalloc(head->num_tags*sizeof(char *));

	tmp->surfs=gcalloc(head->num_surfaces*sizeof(quake_md3surf_t *));

	vfseek(fd, head->ofs_frames, 0);
	for(i=0; i<head->num_frames; i++)
	{
		for(j=0; j<10; j++)ReadFloat32LE(fd);
		vfread(namebuf, 1, 16, fd);
		printf("frame name: '%s'\n", namebuf);
	}

	vfseek(fd, head->ofs_tags, 0);
	for(i=0; i<head->num_tags; i++)
	{
		vfread(namebuf, 1, 64, fd);
		printf("tag name: '%s'\n", namebuf);
		printf("tag values:");
		for(j=0; j<12; j++)
		{
			tmp->tags[(i*12)+j]=ReadFloat32LE(fd);
			printf(" %f", tmp->tags[(i*12)+j]);
		}
		printf("\n");
	}

	base=head->ofs_surfaces;
	for(i=0; i<head->num_surfaces; i++)
	{
		vfseek(fd, base, 0);

		surf=gcalloc(sizeof(quake_md3surf_t));
		tmp->surfs[i]=surf;

		surf->ident=ReadInt32LE(fd);
		vfread(surf->name, 1, 64, fd);
		surf->flags=ReadInt32LE(fd);
		surf->num_frames=ReadInt32LE(fd);
		surf->num_shaders=ReadInt32LE(fd);
		surf->num_verts=ReadInt32LE(fd);
		surf->num_triangles=ReadInt32LE(fd);
		surf->ofs_triangles=ReadInt32LE(fd);
		surf->ofs_shaders=ReadInt32LE(fd);
		surf->ofs_st=ReadInt32LE(fd);
		surf->ofs_xyz=ReadInt32LE(fd);
		surf->ofs_end=ReadInt32LE(fd);

		printf("surface name: '%s'\n", surf->name);
		printf("surface frames: %d shaders: %d verts: %d tris: %d\n",
			surf->num_frames, surf->num_shaders, surf->num_verts,
			surf->num_triangles);

		surf->tris=gcalloc(3*surf->num_triangles*sizeof(int));
		surf->shaders=gcalloc(surf->num_shaders*sizeof(char *));
		surf->st=gcalloc(2*surf->num_verts*sizeof(int));
		surf->frames=gcalloc(surf->num_frames*sizeof(float *));
		surf->sdrnums=gcalloc(surf->num_shaders*sizeof(int));

		vfseek(fd, base+surf->ofs_triangles, 0);
		for(j=0; j<surf->num_triangles; j++)
		{
			surf->tris[(j*3)+0]=ReadInt32LE(fd);
			surf->tris[(j*3)+1]=ReadInt32LE(fd);
			surf->tris[(j*3)+2]=ReadInt32LE(fd);
		}

		vfseek(fd, base+surf->ofs_shaders, 0);
		for(j=0; j<surf->num_shaders; j++)
		{
			vfread(namebuf, 1, 64, fd);
			surf->shaders[j]=dystrdup(namebuf);
			ReadInt32LE(fd);

			s=namebuf+strlen(namebuf);
			while((s>namebuf) && (*s!='/') && (*s!='.'))s--;
			if(*s=='.')*s=0;

			printf("shader name: '%s'\n", namebuf);

			surf->sdrnums[j]=LBXGL_Texture_LoadImage(namebuf);
			if(surf->sdrnums[j]<0)
			{
				printf("missing skin %s\n", namebuf);
				surf->sdrnums[j]=0;
			}
#if 0
			skinbuf=Tex_LoadFileRaw(namebuf, &w, &h);
			if(skinbuf)
			{
				surf->sdrnums[j]=Tex_LoadTexture(w, h,
					skinbuf, 1);
				free(skinbuf);
			}else
			{
				printf("missing skin %s\n", namebuf);
			}
#endif
		}

		vfseek(fd, base+surf->ofs_st, 0);
		for(j=0; j<surf->num_verts; j++)
		{
			surf->st[(j*2)+0]=ReadFloat32LE(fd);
			surf->st[(j*2)+1]=ReadFloat32LE(fd);

//			printf("st(%d): %f %f\n", j,
//				surf->st[(j*2)+0], surf->st[(j*2)+1]);
		}

		vfseek(fd, base+surf->ofs_xyz, 0);
		for(j=0; j<surf->num_frames; j++)
		{
			vecbuf=gcalloc(3*surf->num_verts*sizeof(float));
			surf->frames[j]=vecbuf;
			for(k=0; k<surf->num_verts; k++)
			{
				vecbuf[(k*3)+0]=ReadInt16LE(fd)/64.0;
				vecbuf[(k*3)+1]=ReadInt16LE(fd)/64.0;
				vecbuf[(k*3)+2]=ReadInt16LE(fd)/64.0;
				ReadInt16LE(fd);

				vecbuf[(k*3)+0]*=QMD3_SCALE;
				vecbuf[(k*3)+1]*=QMD3_SCALE;
				vecbuf[(k*3)+2]*=QMD3_SCALE;
			}
		}

		base=base+surf->ofs_end;
	}

	printf("\n");

	return(tmp);
}
コード例 #29
0
ファイル: fmt_qmd3.c プロジェクト: cr88192/bgbtech_engine
int LBXGL_QuakeMD4_LoadSurfs(LBXGL_QMDL *tmp,
	quake_md4lod_t *lod, VFILE *fd, int base)
{
	quake_qmdl_t *head;
	quake_md3surf_t *surf;
	quake_md4vertex_t *vert;
	int i, j, k;
	char namebuf[65];

	head=&tmp->head;

	lod->surfs=gcalloc(lod->num_surfaces*sizeof(quake_md3surf_t *));
	base+=lod->ofs_surfaces;

	for(i=0; i<lod->num_surfaces; i++)
	{
		vfseek(fd, base, 0);

		surf=gcalloc(sizeof(quake_md3surf_t));
		tmp->surfs[i]=surf;

		surf->ident=ReadInt32LE(fd);
		vfread(surf->name, 1, 64, fd);
		vfread(surf->shader, 1, 64, fd);
		ReadInt32LE(fd);
		surf->ofs_header=ReadInt32LE(fd);

		surf->num_verts=ReadInt32LE(fd);
		surf->ofs_verts=ReadInt32LE(fd);

		surf->num_triangles=ReadInt32LE(fd);
		surf->ofs_triangles=ReadInt32LE(fd);

		surf->num_bonerefs=ReadInt32LE(fd);
		surf->ofs_bonerefs=ReadInt32LE(fd);
		surf->ofs_end=ReadInt32LE(fd);

		printf("surface name: '%s'\n", surf->name);
		printf("surface shader: '%s'\n", surf->shader);
		printf("surface verts: %d tris: %d bonerefs: %d\n",
			surf->num_verts, surf->num_triangles,
			surf->num_bonerefs);

		surf->tris=gcalloc(3*surf->num_triangles*sizeof(int));
		surf->md4verts=gcalloc(surf->num_verts*sizeof(quake_md4vertex_t *));
		surf->bonerefs=gcalloc(surf->num_bonerefs*sizeof(int));

		vfseek(fd, base+surf->ofs_verts, 0);
		for(j=0; j<surf->num_verts; j++)
		{
			vert=gcalloc(sizeof(quake_md4vertex_t));
			surf->md4verts[j]=vert;

			for(k=0; k<3; k++)
				vert->vertex[k]=ReadFloat32LE(fd);
			for(k=0; k<3; k++)
				vert->normal[k]=ReadFloat32LE(fd);
			for(k=0; k<2; k++)
				vert->st[k]=ReadFloat32LE(fd);

			vert->num_weights=ReadInt32LE(fd);
			vert->bone_indices=gcalloc(vert->num_weights*sizeof(int));
			vert->bone_weights=gcalloc(vert->num_weights*sizeof(float));

			for(k=0; k<vert->num_weights; k++)
			{
				vert->bone_indices[k]=ReadInt32LE(fd);
				vert->bone_weights[k]=ReadFloat32LE(fd);
			}
		}

		vfseek(fd, base+surf->ofs_triangles, 0);
		for(j=0; j<surf->num_triangles; j++)
		{
			surf->tris[(j*3)+0]=ReadInt32LE(fd);
			surf->tris[(j*3)+1]=ReadInt32LE(fd);
			surf->tris[(j*3)+2]=ReadInt32LE(fd);
		}

		vfseek(fd, base+surf->ofs_bonerefs, 0);
		for(j=0; j<surf->num_bonerefs; j++)
			surf->bonerefs[i]=ReadInt32LE(fd);

		base=base+surf->ofs_end;
	}
	return(0);
}
コード例 #30
0
ファイル: fmt_qmd3.c プロジェクト: cr88192/bgbtech_engine
LBXGL_QMDL *LBXGL_QuakeMD4_StageLoad(LBXGL_QMDL *tmp, VFILE *fd)
{
	quake_qmdl_t *head;
	float *vecbuf;
	quake_md3surf_t *surf;
	quake_md4lod_t *lod;
	int i, j, k, base;
	char namebuf[65];

	printf("loading md4 %s\n", tmp->name);
	head=&tmp->head;

//	head->ident=ReadInt32LE(fd);
//	head->version=ReadInt32LE(fd);

	if(head->ident!=QMD4_ID)
	{
		printf("LBXGL_QuakeMD4_Load(%s): Invalid Ident\n", tmp->name);
		return(NULL);
	}
	if(head->version!=QMD4_VERSION)
	{
		printf("LBXGL_QuakeMD4_Load(%s): Invalid Version\n", tmp->name);
		return(NULL);
	}
	vfread(namebuf, 1, 64, fd);

	head->num_frames=ReadInt32LE(fd);
	head->num_bones=ReadInt32LE(fd);
	head->ofs_frames=ReadInt32LE(fd);

	head->num_lods=ReadInt32LE(fd);
	head->ofs_lods=ReadInt32LE(fd);

	head->ofs_end=ReadInt32LE(fd);

	tmp->frames=gcalloc(head->num_frames*sizeof(float *));
	tmp->framenames=gcalloc(head->num_frames*sizeof(char *));

	tmp->lods=gcalloc(head->num_lods*sizeof(quake_md4lod_t *));

	vfseek(fd, head->ofs_frames, 0);
	for(i=0; i<head->num_frames; i++)
	{
		for(j=0; j<10; j++)ReadFloat32LE(fd);
		vfread(namebuf, 1, 16, fd);
		printf("frame name: '%s'\n", namebuf);

		tmp->frames[i]=gcalloc(12*head->num_bones*sizeof(float));
		vecbuf=tmp->frames[i];

		for(j=0; j<head->num_bones*12; j++)
			vecbuf[j]=ReadFloat32LE(fd);
	}

	base=head->ofs_lods;
	for(i=0; i<head->num_lods; i++)
	{
		vfseek(fd, base, 0);

		lod=gcalloc(sizeof(quake_md4lod_t));
		tmp->lods[i]=lod;

		lod->num_surfaces=ReadInt32LE(fd);
		lod->ofs_surfaces=ReadInt32LE(fd);
		lod->ofs_end=ReadInt32LE(fd);

		printf("lod: %d surfs: %d\n", i, lod->num_surfaces);

		LBXGL_QuakeMD4_LoadSurfs(tmp, lod, fd, base);

		base+=lod->ofs_end;
	}

	return(0);
}