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; }
int32 NetEDIOPWMfd(NetEDIO *ob,int32 num,uint32 freq,uint32 DC) { Stream *out = ob->out; int ret_len; int32 ret; WriteInt16LE(ob->out,0x000A); WriteInt8LE(ob->out,ob->instance); WriteInt8LE(ob->out,0x06); WriteInt32LE(ob->out,num); WriteUInt32LE(ob->out,freq); WriteUInt32LE(ob->out,DC); 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) != 0x06) 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; }
void NetBusPoke32(NetBus *ob,int32 Address,uint32 Value) { Stream *out = ob->out; int ret_len; WriteInt16LE(ob->out,0x0001); WriteInt8LE(ob->out,ob->instance); WriteInt8LE(ob->out,0x08); WriteInt32LE(ob->out,Address); WriteUInt32LE(ob->out,Value); if (ob->conn->mode > 0) ob->conn->count++; if (ob->conn->mode < 2) ob->out->Flush(ob->out); if (ob->conn->mode > 0) return; if (ReadInt16LE(ob->in) != 0x0001) longjmp(ob->conn->exception,1); if (ReadUInt8LE(ob->in) != 0x08) longjmp(ob->conn->exception,2); if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2); }
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; }
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; }
int32 NetBusUnlock(NetBus *ob,uint32 num,int32 flags) { Stream *out = ob->out; int ret_len; int32 ret; WriteInt16LE(ob->out,0x0001); 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) != 0x0001) longjmp(ob->conn->exception,1); if (ReadUInt8LE(ob->in) != 0x01) 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; }
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; }