energy changed

This commit is contained in:
sun
2019-07-12 23:07:02 +08:00
parent f40bfbf5d2
commit 6cafefd7bd
2 changed files with 7 additions and 2 deletions

View File

@@ -227,7 +227,12 @@ bool Serial::InitPort(int nSpeed, char nEvent, int nBits, int nStop) {
bool Serial::WriteData(const unsigned char *pData, unsigned int length) {
int cnt = 0, curr = 0;
if (fd <= 0)return false;
if (fd <= 0){
if(wait_uart){
InitPort(nSpeed, nEvent, nBits, nStop);
}
return false;
}
while ((curr = write(fd, pData + cnt, length - cnt)) > 0 && (cnt += curr) < length);
if (cnt < 0) {
LOGE("Serial offline!");