git-svn-id: svn://db.shs.com.ru/pip@167 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -209,6 +209,10 @@ void PIBinaryLog::createNewFile(const PIString &path) {
|
|||||||
|
|
||||||
int PIBinaryLog::writeBinLog(int id, const void *data, int size) {
|
int PIBinaryLog::writeBinLog(int id, const void *data, int size) {
|
||||||
if (size <= 0 || !canWrite()) return -1;
|
if (size <= 0 || !canWrite()) return -1;
|
||||||
|
if (id == 0) {
|
||||||
|
piCoutObj << "Error: can`t write with id = 0!";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
switch (split_mode) {
|
switch (split_mode) {
|
||||||
case SplitSize:
|
case SplitSize:
|
||||||
if (logSize() > split_size) createNewFile();
|
if (logSize() > split_size) createNewFile();
|
||||||
@@ -243,7 +247,7 @@ int PIBinaryLog::writeBinLog_raw(int id, const PISystemTime &time, const void *d
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIByteArray PIBinaryLog::readBinLog(int id) {
|
PIByteArray PIBinaryLog::readBinLog(int id, PISystemTime * time) {
|
||||||
if (!canRead()) return PIByteArray();
|
if (!canRead()) return PIByteArray();
|
||||||
BinLogRecord br = readRecord();
|
BinLogRecord br = readRecord();
|
||||||
if (br.id == -1) {
|
if (br.id == -1) {
|
||||||
@@ -258,15 +262,19 @@ PIByteArray PIBinaryLog::readBinLog(int id) {
|
|||||||
fileEnd();
|
fileEnd();
|
||||||
return PIByteArray();
|
return PIByteArray();
|
||||||
}
|
}
|
||||||
if (br.id == id) return br.data;
|
if (br.id == id) {
|
||||||
|
if (time)
|
||||||
|
*time = br.timestamp;
|
||||||
|
return br.data;
|
||||||
|
}
|
||||||
piCoutObj << "Can't find record with id =" << id;
|
piCoutObj << "Can't find record with id =" << id;
|
||||||
return PIByteArray();
|
return PIByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIBinaryLog::readBinLog(int id, void *read_to, int max_size) {
|
int PIBinaryLog::readBinLog(int id, void *read_to, int max_size, PISystemTime * time) {
|
||||||
if (max_size <= 0 || read_to == 0) return -1;
|
if (max_size <= 0 || read_to == 0) return -1;
|
||||||
PIByteArray ba = readBinLog(id);
|
PIByteArray ba = readBinLog(id, time);
|
||||||
if (ba.isEmpty()) return -1;
|
if (ba.isEmpty()) return -1;
|
||||||
int sz = piMini(max_size, ba.size());
|
int sz = piMini(max_size, ba.size());
|
||||||
memcpy(read_to, ba.data(), sz);
|
memcpy(read_to, ba.data(), sz);
|
||||||
|
|||||||
@@ -179,10 +179,10 @@ public:
|
|||||||
int writeCount() const {return write_count;}
|
int writeCount() const {return write_count;}
|
||||||
|
|
||||||
//! Read one record from BinLog file, with ID = id, if id = 0 than any id will be readed
|
//! Read one record from BinLog file, with ID = id, if id = 0 than any id will be readed
|
||||||
PIByteArray readBinLog(int id = 0);
|
PIByteArray readBinLog(int id = 0, PISystemTime * time = 0);
|
||||||
|
|
||||||
//! Read one record from BinLog file, with ID = id, if id = 0 than any id will be readed
|
//! Read one record from BinLog file, with ID = id, if id = 0 than any id will be readed
|
||||||
int readBinLog(int id, void * read_to, int max_size);
|
int readBinLog(int id, void * read_to, int max_size, PISystemTime * time = 0);
|
||||||
|
|
||||||
//! Returns binary log file size
|
//! Returns binary log file size
|
||||||
llong logSize() const {return file.size();}
|
llong logSize() const {return file.size();}
|
||||||
|
|||||||
@@ -47,7 +47,14 @@
|
|||||||
# define B57600 57600
|
# define B57600 57600
|
||||||
# define B115200 115200
|
# define B115200 115200
|
||||||
# define B128000 128000
|
# define B128000 128000
|
||||||
|
# define B230400 230400
|
||||||
# define B256000 256000
|
# define B256000 256000
|
||||||
|
# define B460800 460800
|
||||||
|
# define B500000 500000
|
||||||
|
# define B576000 576000
|
||||||
|
# define B921600 921600
|
||||||
|
# define B1000000 1000000
|
||||||
|
# define B1152000 1152000
|
||||||
# define B1500000 1500000
|
# define B1500000 1500000
|
||||||
# define B2000000 2000000
|
# define B2000000 2000000
|
||||||
# define B2500000 2500000
|
# define B2500000 2500000
|
||||||
@@ -64,6 +71,27 @@
|
|||||||
# ifndef B75
|
# ifndef B75
|
||||||
# define B75 0000002
|
# define B75 0000002
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef B230400
|
||||||
|
# define B230400 0010003
|
||||||
|
# endif
|
||||||
|
# ifndef B460800
|
||||||
|
# define B460800 0010004
|
||||||
|
# endif
|
||||||
|
# ifndef B500000
|
||||||
|
# define B500000 0010005
|
||||||
|
# endif
|
||||||
|
# ifndef B576000
|
||||||
|
# define B576000 0010006
|
||||||
|
# endif
|
||||||
|
# ifndef B921600
|
||||||
|
# define B921600 0010007
|
||||||
|
# endif
|
||||||
|
# ifndef B1000000
|
||||||
|
# define B1000000 0010010
|
||||||
|
# endif
|
||||||
|
# ifndef B1152000
|
||||||
|
# define B1152000 0010011
|
||||||
|
# endif
|
||||||
# ifndef B1500000
|
# ifndef B1500000
|
||||||
# define B1500000 0010012
|
# define B1500000 0010012
|
||||||
# endif
|
# endif
|
||||||
@@ -299,6 +327,15 @@ int PISerial::convertSpeed(PISerial::Speed speed) {
|
|||||||
case S38400: return B38400;
|
case S38400: return B38400;
|
||||||
case S57600: return B57600;
|
case S57600: return B57600;
|
||||||
case S115200: return B115200;
|
case S115200: return B115200;
|
||||||
|
case S128000: return B128000;
|
||||||
|
case S230400: return B230400;
|
||||||
|
case S256000: return B256000;
|
||||||
|
case S460800: return B460800;
|
||||||
|
case S500000: return B500000;
|
||||||
|
case S576000: return B576000;
|
||||||
|
case S921600: return B921600;
|
||||||
|
case S1000000: return B1000000;
|
||||||
|
case S1152000: return B1152000;
|
||||||
case S1500000: return B1500000;
|
case S1500000: return B1500000;
|
||||||
case S2000000: return B2000000;
|
case S2000000: return B2000000;
|
||||||
case S2500000: return B2500000;
|
case S2500000: return B2500000;
|
||||||
|
|||||||
@@ -56,12 +56,21 @@ public:
|
|||||||
S38400 /*! 38400 baud */ = 38400,
|
S38400 /*! 38400 baud */ = 38400,
|
||||||
S57600 /*! 57600 baud */ = 57600,
|
S57600 /*! 57600 baud */ = 57600,
|
||||||
S115200 /*! 115200 baud */ = 115200,
|
S115200 /*! 115200 baud */ = 115200,
|
||||||
S1500000 = 1500000, // Linux only
|
S128000 /*! 128000 baud */ = 128000,
|
||||||
S2000000 = 2000000, // Linux only
|
S230400 /*! 230400 baud */ = 230400,
|
||||||
S2500000 = 2500000, // Linux only
|
S256000 /*! 256000 baud */ = 256000,
|
||||||
S3000000 = 3000000, // Linux only
|
S460800 /*! 460800 baud */ = 460800,
|
||||||
S3500000 = 3500000, // Linux only
|
S500000 /*! 500000 baud */ = 500000,
|
||||||
S4000000 = 4000000 // Linux only
|
S576000 /*! 576000 baud */ = 576000,
|
||||||
|
S921600 /*! 921600 baud */ = 921600,
|
||||||
|
S1000000 /*! 1000000 baud */ = 1000000,
|
||||||
|
S1152000 /*! 1152000 baud */ = 1152000,
|
||||||
|
S1500000 /*! 1500000 baud */ = 1500000,
|
||||||
|
S2000000 /*! 2000000 baud */ = 2000000,
|
||||||
|
S2500000 /*! 2500000 baud */ = 2500000,
|
||||||
|
S3000000 /*! 3000000 baud */ = 3000000,
|
||||||
|
S3500000 /*! 3500000 baud */ = 3500000,
|
||||||
|
S4000000 /*! 4000000 baud */ = 4000000
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Contructs %PISerial with device name "device", speed "speed" and parameters "params"
|
//! Contructs %PISerial with device name "device", speed "speed" and parameters "params"
|
||||||
|
|||||||
Reference in New Issue
Block a user