Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/HLSCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
#include "HLSCL.h"

HLSCL::HLSCL()
: SCSerial(0)
, Mem{}
{
End = 0;
}

HLSCL::HLSCL(u8 End):SCSerial(End)
HLSCL::HLSCL(u8 End)
: SCSerial(End)
, Mem{}
{
}

HLSCL::HLSCL(u8 End, u8 Level):SCSerial(End, Level)
HLSCL::HLSCL(u8 End, u8 Level)
: SCSerial(End, Level)
, Mem{}
{
}

Expand Down
41 changes: 33 additions & 8 deletions src/SCS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,48 @@
#include "SCS.h"

SCS::SCS()
: Level(1)
, End(0)
, u8Status(0)
, u8Error(0)
, syncReadRxPacketIndex(0)
, syncReadRxPacketLen(0)
, syncReadRxPacket(nullptr)
, syncReadRxBuff(nullptr)
, syncReadRxBuffLen(0)
, syncReadRxBuffMax(0)
, syncTimeOut(0)
{
Level = 1;//除广播指令所有指令返回应答
u8Status = 0;
}

SCS::SCS(u8 End)
: Level(1)
, End(End)
, u8Status(0)
, u8Error(0)
, syncReadRxPacketIndex(0)
, syncReadRxPacketLen(0)
, syncReadRxPacket(nullptr)
, syncReadRxBuff(nullptr)
, syncReadRxBuffLen(0)
, syncReadRxBuffMax(0)
, syncTimeOut(0)
{
Level = 1;
this->End = End;
u8Status = 0;
}

SCS::SCS(u8 End, u8 Level)
: Level(Level)
, End(End)
, u8Status(0)
, u8Error(0)
, syncReadRxPacketIndex(0)
, syncReadRxPacketLen(0)
, syncReadRxPacket(nullptr)
, syncReadRxBuff(nullptr)
, syncReadRxBuffLen(0)
, syncReadRxBuffMax(0)
, syncTimeOut(0)
{
this->Level = Level;
this->End = End;
u8Status = 0;
}

//1个16位数拆分为2个8位数
Expand Down
1 change: 1 addition & 0 deletions src/SCS.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SCS{
SCS();
SCS(u8 End);
SCS(u8 End, u8 Level);
virtual ~SCS() = default;
int genWrite(u8 ID, u8 MemAddr, u8 *nDat, u8 nLen);//普通写指令
int regWrite(u8 ID, u8 MemAddr, u8 *nDat, u8 nLen);//异步写指令
int RegWriteAction(u8 ID = 0xfe);//异步写执行指令
Expand Down
11 changes: 8 additions & 3 deletions src/SCSCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
#include "SCSCL.h"

SCSCL::SCSCL()
: SCSerial(1)
, Mem{}
{
End = 1;
}

SCSCL::SCSCL(u8 End):SCSerial(End)
SCSCL::SCSCL(u8 End)
: SCSerial(End)
, Mem{}
{
}

SCSCL::SCSCL(u8 End, u8 Level):SCSerial(End, Level)
SCSCL::SCSCL(u8 End, u8 Level)
: SCSerial(End, Level)
, Mem{}
{
}

Expand Down
39 changes: 28 additions & 11 deletions src/SCSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,41 @@
#include "SCSerial.h"

SCSerial::SCSerial()
: SCS()
, IOTimeOut(100)
, fd(-1)
, orgopt{}
, curopt{}
, txBufLen(0)
{
IOTimeOut = 100;
fd = -1;
txBufLen = 0;
}

SCSerial::SCSerial(u8 End):SCS(End)
SCSerial::SCSerial(u8 End)
: SCS(End)
, IOTimeOut(100)
, fd(-1)
, orgopt{}
, curopt{}
, txBufLen(0)
{
IOTimeOut = 100;
fd = -1;
txBufLen = 0;
}

SCSerial::SCSerial(u8 End, u8 Level):SCS(End, Level)
SCSerial::SCSerial(u8 End, u8 Level)
: SCS(End, Level)
, IOTimeOut(100)
, fd(-1)
, orgopt{}
, curopt{}
, txBufLen(0)
{
IOTimeOut = 100;
fd = -1;
txBufLen = 0;
}

SCSerial::~SCSerial()
{
if(fd != -1){
close(fd);
fd = -1;
}
}

bool SCSerial::begin(int baudRate, const char* serialPort)
Expand Down
13 changes: 7 additions & 6 deletions src/SCSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class SCSerial : public SCS
SCSerial();
SCSerial(u8 End);
SCSerial(u8 End, u8 Level);
~SCSerial() override;

protected:
int writeSCS(unsigned char *nDat, int nLen);//输出nLen字节
int readSCS(unsigned char *nDat, int nLen);//输入nLen字节
int readSCS(unsigned char *nDat, int nLen, unsigned long TimeOut);
int writeSCS(unsigned char bDat);//输出1字节
void rFlushSCS();//
void wFlushSCS();//
int writeSCS(unsigned char *nDat, int nLen) override;//输出nLen字节
int readSCS(unsigned char *nDat, int nLen) override;//输入nLen字节
int readSCS(unsigned char *nDat, int nLen, unsigned long TimeOut) override;
int writeSCS(unsigned char bDat) override;//输出1字节
void rFlushSCS() override;//
void wFlushSCS() override;//
public:
unsigned long int IOTimeOut;//输入输出超时
public:
Expand Down
11 changes: 8 additions & 3 deletions src/SMS_STS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
#include "SMS_STS.h"

SMS_STS::SMS_STS()
: SCSerial(0)
, Mem{}
{
End = 0;
}

SMS_STS::SMS_STS(u8 End):SCSerial(End)
SMS_STS::SMS_STS(u8 End)
: SCSerial(End)
, Mem{}
{
}

SMS_STS::SMS_STS(u8 End, u8 Level):SCSerial(End, Level)
SMS_STS::SMS_STS(u8 End, u8 Level)
: SCSerial(End, Level)
, Mem{}
{
}

Expand Down