/* * SCSCL.cpp * 飞特SCSCL系列串行舵机应用层程序 * 日期: 2020.6.17 * 作者: */ #include "SCSCL.h" SCSCL::SCSCL() { End = 1; } SCSCL::SCSCL(u8 End):SCSerial(End) { } SCSCL::SCSCL(u8 End, u8 Level):SCSerial(End, Level) { } int SCSCL::WritePos(u8 ID, u16 Position, u16 Time, u16 Speed) { u8 bBuf[6]; Host2SCS(bBuf+0, bBuf+1, Position); Host2SCS(bBuf+2, bBuf+3, Time); Host2SCS(bBuf+4, bBuf+5, Speed); return genWrite(ID, SCSCL_GOAL_POSITION_L, bBuf, 6); } int SCSCL::WritePosEx(u8 ID, s16 Position, u16 Speed, u8 ACC) { ACC = 0; u16 Time = 0; u8 bBuf[6]; Host2SCS(bBuf+0, bBuf+1, Position); Host2SCS(bBuf+2, bBuf+3, Time); Host2SCS(bBuf+4, bBuf+5, Speed); return genWrite(ID, SCSCL_GOAL_POSITION_L, bBuf, 6); } int SCSCL::RegWritePos(u8 ID, u16 Position, u16 Time, u16 Speed) { u8 bBuf[6]; Host2SCS(bBuf+0, bBuf+1, Position); Host2SCS(bBuf+2, bBuf+3, Time); Host2SCS(bBuf+4, bBuf+5, Speed); return regWrite(ID, SCSCL_GOAL_POSITION_L, bBuf, 6); } int SCSCL::CalibrationOfs(u8 ID){ return -1; } void SCSCL::SyncWritePos(u8 ID[], u8 IDN, u16 Position[], u16 Time[], u16 Speed[]) { u8 offbuf[6*IDN]; for(u8 i = 0; i 0){ return 0; } // int Mode = -1; // if(ID==-1){ // Mode = Mem[SMS_STS_MODE-SMS_STS_PRESENT_POSITION_L]; // }else{ // Err = 0; // Mode = readByte(ID, SMS_STS_MODE); // if(Mode==-1){ // Err = 1; // } // } return ValueRead; } int SCSCL::ReadInfoValue(int ID, int AddInput) { int ValueRead = -1; ValueRead = readWord(ID, AddInput); return ValueRead; } int SCSCL::ReadCurrent(int ID) { int Current = -1; if(ID==-1){ Current = Mem[SCSCL_PRESENT_CURRENT_L-SCSCL_PRESENT_POSITION_L]; Current <<= 8; Current |= Mem[SCSCL_PRESENT_CURRENT_H-SCSCL_PRESENT_POSITION_L]; }else{ Err = 0; Current = readWord(ID, SCSCL_PRESENT_CURRENT_L); if(Current==-1){ Err = 1; return -1; } } if(!Err && (Current&(1<<15))){ Current = -(Current&~(1<<15)); } return Current; }