first release of translation facility
* runtime - loading and translating * design-time - works with *.ts file (pip_tr utility) * compile-time - CMake macro for compile *.ts
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "piliterals_time.h"
|
||||
#include "pipropertystorage.h"
|
||||
#include "pitime.h"
|
||||
#include "pitranslator.h"
|
||||
|
||||
#define PIBINARYLOG_VERSION_OLD 0x31
|
||||
|
||||
@@ -100,7 +101,7 @@ bool PIBinaryLog::openDevice() {
|
||||
index.clear();
|
||||
log_size = 0;
|
||||
if (mode_ == ReadWrite) {
|
||||
piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly";
|
||||
piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly"_tr("PIBinLog");
|
||||
return false;
|
||||
}
|
||||
if (path().isEmpty() && mode_ == WriteOnly) {
|
||||
@@ -122,21 +123,21 @@ bool PIBinaryLog::openDevice() {
|
||||
}
|
||||
}
|
||||
if (!file.open(path(), mode_)) {
|
||||
piCoutObj << "Error: Can't open file" << path();
|
||||
piCoutObj << "Error: Can't open file \"%1\": %2"_tr("PIBinLog").arg(path()).arg(errorString());
|
||||
return false;
|
||||
}
|
||||
setName(path());
|
||||
if (mode_ == WriteOnly) {
|
||||
file.clear();
|
||||
if (!writeFileHeader()) {
|
||||
piCoutObj << "Error: Can't write binlog file header" << path();
|
||||
piCoutObj << "Error: Can't write binlog file header \"%1\""_tr("PIBinLog").arg(path());
|
||||
return false;
|
||||
}
|
||||
is_started = true;
|
||||
}
|
||||
if (mode_ == ReadOnly) {
|
||||
if (file.isEmpty()) {
|
||||
piCoutObj << "Error: File is null" << path();
|
||||
piCoutObj << "Error: File is null \"%1\""_tr("PIBinLog").arg(path());
|
||||
fileError();
|
||||
return false;
|
||||
}
|
||||
@@ -145,7 +146,7 @@ bool PIBinaryLog::openDevice() {
|
||||
return false;
|
||||
}
|
||||
if (isEmpty()) {
|
||||
piCoutObj << "Warning: Empty BinLog file" << path();
|
||||
piCoutObj << "Warning: Empty BinLog file \"%1\""_tr("PIBinLog").arg(path());
|
||||
fileEnd();
|
||||
}
|
||||
play_time = 0;
|
||||
@@ -175,7 +176,7 @@ bool PIBinaryLog::closeDevice() {
|
||||
|
||||
|
||||
bool PIBinaryLog::threadedRead(const uchar * readed, ssize_t size) {
|
||||
// piCout << "binlog threaded read";
|
||||
// piCout << "binlog threaded read";
|
||||
if (!canRead() || isEnd()) return PIIODevice::threadedRead(readed, size);
|
||||
is_thread_ok = false;
|
||||
logmutex.lock();
|
||||
@@ -258,7 +259,7 @@ PIString PIBinaryLog::getLogfilePath(const PIString & log_dir, const PIString &
|
||||
dir.setDir(dir.absolutePath());
|
||||
if (!dir.isExists()) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Creating directory" << dir.path();
|
||||
<< "Creating directory \"%1\""_tr("PIBinLog").arg(dir.path());
|
||||
dir.make(true);
|
||||
}
|
||||
const PIString npath = log_dir + PIDir::separator + prefix + PIDateTime::current().toString("yyyy_MM_dd__hh_mm_ss");
|
||||
@@ -282,7 +283,7 @@ PIString PIBinaryLog::createNewFile() {
|
||||
newFile(file.path());
|
||||
return file.path();
|
||||
}
|
||||
piCoutObj << "Can't create new file, maybe LogDir" << ("\"" + logDir() + "\"") << "is invalid.";
|
||||
piCoutObj << "Can't create new file, maybe LogDir \"%1\" is invalid"_tr("PIBinLog").arg(logDir());
|
||||
return PIString();
|
||||
}
|
||||
|
||||
@@ -291,7 +292,7 @@ void PIBinaryLog::createNewFile(const PIString & path) {
|
||||
if (open(path, PIIODevice::WriteOnly)) {
|
||||
newFile(file.path());
|
||||
} else
|
||||
piCoutObj << "Can't create new file, maybe path" << ("\"" + path + "\"") << "is invalid.";
|
||||
piCoutObj << "Can't create new file, maybe path \"%1\" is invalid"_tr("PIBinLog").arg(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -315,7 +316,7 @@ void PIBinaryLog::setPause(bool pause) {
|
||||
int PIBinaryLog::writeBinLog(int id, const void * data, int size) {
|
||||
if (size <= 0 || !canWrite()) return -1;
|
||||
if (id == 0) {
|
||||
piCoutObj << "Error: can`t write with id = 0! Id must be > 0";
|
||||
piCoutObj << "Error: can`t write with id = 0! ID must be > 0"_tr("PIBinLog");
|
||||
return -1;
|
||||
}
|
||||
if (is_pause) return 0;
|
||||
@@ -359,7 +360,7 @@ PIByteArray PIBinaryLog::readBinLog(int id, PISystemTime * time, int * readed_id
|
||||
Record br = readRecord();
|
||||
logmutex.unlock();
|
||||
if (br.id == -1) {
|
||||
piCoutObj << "End of BinLog file";
|
||||
piCoutObj << "End of BinLog file"_tr("PIBinLog");
|
||||
fileEnd();
|
||||
return PIByteArray();
|
||||
}
|
||||
@@ -373,7 +374,7 @@ PIByteArray PIBinaryLog::readBinLog(int id, PISystemTime * time, int * readed_id
|
||||
br = readRecord();
|
||||
logmutex.unlock();
|
||||
if (br.id == -1) {
|
||||
piCoutObj << "End of BinLog file";
|
||||
piCoutObj << "End of BinLog file"_tr("PIBinLog");
|
||||
fileEnd();
|
||||
return PIByteArray();
|
||||
}
|
||||
@@ -382,7 +383,7 @@ PIByteArray PIBinaryLog::readBinLog(int id, PISystemTime * time, int * readed_id
|
||||
if (readed_id) *readed_id = br.id;
|
||||
return br.data;
|
||||
}
|
||||
piCoutObj << "Can't find record with id =" << id;
|
||||
piCoutObj << "Can't find record with id = %1"_tr("PIBinLog").arg(id);
|
||||
return PIByteArray();
|
||||
}
|
||||
|
||||
@@ -428,15 +429,15 @@ ssize_t PIBinaryLog::readDevice(void * read_to, ssize_t max_size) {
|
||||
}
|
||||
if (br.id == -1) {
|
||||
fileEnd();
|
||||
piCoutObj << "End of BinLog file";
|
||||
piCoutObj << "End of BinLog file"_tr("PIBinLog");
|
||||
return 0;
|
||||
}
|
||||
if (br.id == 0) {
|
||||
piCoutObj << "Read record error";
|
||||
piCoutObj << "Read record error"_tr("PIBinLog");
|
||||
return -1;
|
||||
}
|
||||
const ssize_t sz = piMini(max_size, br.data.size());
|
||||
if (sz < br.data.size_s()) piCoutObj << "too small read buffer:" << max_size << ", data size:" << br.data.size();
|
||||
if (sz < br.data.size_s()) piCoutObj << "too small read buffer: %1, data size: %2"_tr("PIBinLog").arg(max_size).arg(br.data.size());
|
||||
memcpy(read_to, br.data.data(), sz);
|
||||
return sz;
|
||||
}
|
||||
@@ -491,7 +492,7 @@ bool PIBinaryLog::checkFileHeader() {
|
||||
for (uint i = 0; i < PIBINARYLOG_SIGNATURE_SIZE; i++)
|
||||
if (read_sig[i] != binlog_sig[i]) correct = false;
|
||||
if (!correct) {
|
||||
piCoutObj << "BinLogFile signature is corrupted or invalid file";
|
||||
piCoutObj << "BinLogFile signature is corrupted or invalid file"_tr("PIBinLog");
|
||||
return false;
|
||||
}
|
||||
uchar read_version = 0;
|
||||
@@ -509,9 +510,9 @@ bool PIBinaryLog::checkFileHeader() {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (read_version == 0) piCoutObj << "BinLogFile has invalid version";
|
||||
if (read_version < PIBINARYLOG_VERSION) piCoutObj << "BinLogFile has too old verion";
|
||||
if (read_version > PIBINARYLOG_VERSION) piCoutObj << "BinLogFile has too newest version";
|
||||
if (read_version == 0) piCoutObj << "BinLogFile has invalid version"_tr("PIBinLog");
|
||||
if (read_version < PIBINARYLOG_VERSION) piCoutObj << "BinLogFile has too old verion"_tr("PIBinLog");
|
||||
if (read_version > PIBINARYLOG_VERSION) piCoutObj << "BinLogFile has too new version"_tr("PIBinLog");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -545,7 +546,7 @@ PIBinaryLog::Record PIBinaryLog::readRecord() {
|
||||
if (br.id == 0) fileError();
|
||||
moveIndex(index.index_pos.value(file.pos(), -1));
|
||||
logmutex.unlock();
|
||||
// piCoutObj << "readRecord done";
|
||||
// piCoutObj << "readRecord done";
|
||||
return br;
|
||||
}
|
||||
|
||||
@@ -721,7 +722,7 @@ bool PIBinaryLog::cutBinLog(const PIBinaryLog::BinLogInfo & src, const PIString
|
||||
PIBinaryLog slog;
|
||||
if (!slog.open(src.path, PIIODevice::ReadOnly)) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't open" << src.path;
|
||||
<< "Error, can't open \"%1\""_tr("PIBinLog").arg(src.path);
|
||||
return false;
|
||||
}
|
||||
const PIVector<int> ids = src.records.keys();
|
||||
@@ -730,7 +731,7 @@ bool PIBinaryLog::cutBinLog(const PIBinaryLog::BinLogInfo & src, const PIString
|
||||
dlog.createNewFile(dst);
|
||||
if (!dlog.isOpened()) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't create" << dst;
|
||||
<< "Error, can't create \"%1\""_tr("PIBinLog").arg(dst);
|
||||
return false;
|
||||
}
|
||||
bool first = true;
|
||||
@@ -746,7 +747,7 @@ bool PIBinaryLog::cutBinLog(const PIBinaryLog::BinLogInfo & src, const PIString
|
||||
if (ids.contains(br.id)) {
|
||||
if (dlog.writeBinLog_raw(br.id, br.timestamp - st, br.data) <= 0) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't write to file" << dst;
|
||||
<< "Error, can't write to file \"%1\""_tr("PIBinLog").arg(dst);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -772,7 +773,7 @@ bool PIBinaryLog::joinBinLogsSerial(const PIStringList & src,
|
||||
for (const PIString & fn: src) {
|
||||
if (!slog.open(fn, PIIODevice::ReadOnly)) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't open" << fn;
|
||||
<< "Error, can't open \"%1\""_tr("PIBinLog").arg(fn);
|
||||
return false;
|
||||
}
|
||||
if (first) {
|
||||
@@ -781,11 +782,11 @@ bool PIBinaryLog::joinBinLogsSerial(const PIStringList & src,
|
||||
dlog.createNewFile(dst);
|
||||
if (!dlog.isOpened()) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't create" << dst;
|
||||
<< "Error, can't create \"%1\""_tr("PIBinLog").arg(dst);
|
||||
return false;
|
||||
}
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Start join binlogs to" << dst;
|
||||
<< "Start join binlogs to \"%1\""_tr("PIBinLog").arg(dst);
|
||||
} else {
|
||||
dtime = lt;
|
||||
}
|
||||
@@ -799,7 +800,7 @@ bool PIBinaryLog::joinBinLogsSerial(const PIStringList & src,
|
||||
lt = dtime + br.timestamp;
|
||||
if (dlog.writeBinLog_raw(br.id, lt, br.data) <= 0) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't write to file" << dst;
|
||||
<< "Error, can't write to file \"%1\""_tr("PIBinLog").arg(dst);
|
||||
return false;
|
||||
}
|
||||
if (tm.elapsed_s() > 0.1) {
|
||||
@@ -821,7 +822,7 @@ bool PIBinaryLog::joinBinLogsSerial(const PIStringList & src,
|
||||
// piCout << "[PIBinaryLog]" << "complete" << fn;
|
||||
}
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Finish join binlogs, total time" << PITime::fromSystemTime(lt).toString();
|
||||
<< "Finish join binlogs, total time %1"_tr("PIBinLog").arg(PITime::fromSystemTime(lt).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -853,7 +854,7 @@ int PIBinaryLog::posForTime(const PISystemTime & time) {
|
||||
|
||||
|
||||
void PIBinaryLog::seekTo(int rindex) {
|
||||
// piCoutObj << "seekTo";
|
||||
// piCoutObj << "seekTo";
|
||||
logmutex.lock();
|
||||
pausemutex.lock();
|
||||
if (rindex < index.index.size_s() && rindex >= 0) {
|
||||
@@ -866,7 +867,7 @@ void PIBinaryLog::seekTo(int rindex) {
|
||||
startlogtime = PISystemTime::current() - lastrecord.timestamp;
|
||||
}
|
||||
}
|
||||
// piCoutObj << "seekTo done";
|
||||
// piCoutObj << "seekTo done";
|
||||
pausemutex.unlock();
|
||||
logmutex.unlock();
|
||||
}
|
||||
@@ -947,7 +948,7 @@ void PIBinaryLog::configureFromFullPathDevice(const PIString & full_path) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// piCoutObj << "configured";
|
||||
// piCoutObj << "configured";
|
||||
}
|
||||
|
||||
|
||||
@@ -989,7 +990,7 @@ void PIBinaryLog::propertyChanged(const char * s) {
|
||||
split_time = property("splitTime").toSystemTime();
|
||||
split_size = property("splitFileSize").toLLong();
|
||||
split_count = property("splitRecordCount").toInt();
|
||||
// piCoutObj << "propertyChanged" << s << play_mode;
|
||||
// piCoutObj << "propertyChanged" << s << play_mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "piliterals.h"
|
||||
#include "pipropertystorage.h"
|
||||
#include "pisysteminfo.h"
|
||||
#include "pitranslator.h"
|
||||
// clang-format off
|
||||
#ifdef QNX
|
||||
# include <arpa/inet.h>
|
||||
@@ -897,7 +898,9 @@ void PIEthernet::server_func(void * eth) {
|
||||
piMSleep(10);
|
||||
return;
|
||||
}
|
||||
if (ce->debug()) piCout << "[PIEthernet] Can`t accept new connection," << ethErrorString();
|
||||
if (ce->debug())
|
||||
piCout << "[PIEthernet]"
|
||||
<< "Can`t accept new connection, %1"_tr("PIEthernet").arg(ethErrorString());
|
||||
piMSleep(50);
|
||||
return;
|
||||
}
|
||||
@@ -1081,14 +1084,16 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
||||
ulong ulOutBufLen = sizeof(IP_ADAPTER_INFO);
|
||||
PIP_ADAPTER_INFO pAdapterInfo = (PIP_ADAPTER_INFO)HeapAlloc(GetProcessHeap(), 0, sizeof(IP_ADAPTER_INFO));
|
||||
if (!pAdapterInfo) {
|
||||
piCout << "[PIEthernet] Error allocating memory needed to call GetAdaptersInfo";
|
||||
piCout << "[PIEthernet]"
|
||||
<< "Error allocating memory needed to call GetAdaptersInfo"_tr("PIEthernet");
|
||||
return il;
|
||||
}
|
||||
if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
|
||||
HeapFree(GetProcessHeap(), 0, pAdapterInfo);
|
||||
pAdapterInfo = (PIP_ADAPTER_INFO)HeapAlloc(GetProcessHeap(), 0, ulOutBufLen);
|
||||
if (!pAdapterInfo) {
|
||||
piCout << "[PIEthernet] Error allocating memory needed to call GetAdaptersInfo";
|
||||
piCout << "[PIEthernet]"
|
||||
<< "Error allocating memory needed to call GetAdaptersInfo"_tr("PIEthernet");
|
||||
return il;
|
||||
}
|
||||
}
|
||||
@@ -1134,7 +1139,8 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
||||
ifc.ifc_len = 256;
|
||||
ifc.ifc_buf = new char[ifc.ifc_len];
|
||||
if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
|
||||
piCout << "[PIEthernet] Can`t get interfaces:" << errorString();
|
||||
piCout << "[PIEthernet]"
|
||||
<< "Can`t get interfaces: %1"_tr("PIEthernet").arg(errorString());
|
||||
delete[] ifc.ifc_buf;
|
||||
return il;
|
||||
}
|
||||
@@ -1223,7 +1229,8 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
||||
}
|
||||
freeifaddrs(ret);
|
||||
} else
|
||||
piCout << "[PIEthernet] Can`t get interfaces:" << errorString();
|
||||
piCout << "[PIEthernet]"
|
||||
<< "Can`t get interfaces: %1"_tr("PIEthernet").arg(errorString());
|
||||
if (s != -1) ::close(s);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "piincludes_p.h"
|
||||
#include "piiostream.h"
|
||||
#include "pitime_win.h"
|
||||
#include "pitranslator.h"
|
||||
#ifdef WINDOWS
|
||||
# undef S_IFDIR
|
||||
# undef S_IFREG
|
||||
@@ -295,7 +296,7 @@ void PIFile::resize(llong new_size, uchar fill_) {
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
piCoutObj << "Downsize is not supported yet :-(";
|
||||
piCoutObj << "Downsize is not supported yet :-("_tr("PIFile");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,12 +56,12 @@ bool PIIOByteArray::open(const PIByteArray & buffer) {
|
||||
|
||||
|
||||
ssize_t PIIOByteArray::readDevice(void * read_to, ssize_t size) {
|
||||
// piCout << "PIIOByteArray::read" << data_ << size << canRead();
|
||||
// piCout << "PIIOByteArray::read" << data_ << size << canRead();
|
||||
if (!canRead() || !data_) return -1;
|
||||
int ret = piMini(size, data_->size_s() - pos);
|
||||
if (ret <= 0) return -1;
|
||||
memcpy(read_to, data_->data(pos), ret);
|
||||
// piCout << "readed" << ret;
|
||||
// piCout << "readed" << ret;
|
||||
pos += size;
|
||||
if (pos > data_->size_s()) pos = data_->size_s();
|
||||
return ret;
|
||||
@@ -69,12 +69,12 @@ ssize_t PIIOByteArray::readDevice(void * read_to, ssize_t size) {
|
||||
|
||||
|
||||
ssize_t PIIOByteArray::writeDevice(const void * data, ssize_t size) {
|
||||
// piCout << "PIIOByteArray::write" << data << size << canWrite();
|
||||
// piCout << "PIIOByteArray::write" << data << size << canWrite();
|
||||
if (!canWrite() || !data) return -1;
|
||||
// piCout << "write" << data;
|
||||
if (pos > data_->size_s()) pos = data_->size_s();
|
||||
PIByteArray rs = PIByteArray(data, size);
|
||||
// piCoutObj << rs;
|
||||
// piCoutObj << rs;
|
||||
data_->insert(pos, rs);
|
||||
pos += rs.size_s();
|
||||
return rs.size_s();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "piliterals_time.h"
|
||||
#include "pipropertystorage.h"
|
||||
#include "pitime.h"
|
||||
#include "pitranslator.h"
|
||||
|
||||
|
||||
//! \class PIIODevice piiodevice.h
|
||||
@@ -222,7 +223,7 @@ void PIIODevice::stopThreadedRead() {
|
||||
if (!destroying) {
|
||||
interrupt();
|
||||
} else {
|
||||
piCoutObj << "Error: Device is running after destructor!";
|
||||
piCoutObj << "Error: Device is running after destructor!"_tr("PIIODevice");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -535,7 +536,7 @@ void PIIODevice::splitFullPath(PIString fpwm, PIString * full_path, DeviceMode *
|
||||
if (fpwm.find('(') > 0 && fpwm.find(')') > 0) {
|
||||
PIString dms(fpwm.right(fpwm.length() - fpwm.findLast('(')).takeRange('(', ')').trim().toLowerCase().removeAll(' '));
|
||||
PIStringList opts(dms.split(","));
|
||||
piForeachC(PIString & o, opts) {
|
||||
for (const auto & o: opts) {
|
||||
// piCout << dms;
|
||||
if (o == "r"_a || o == "ro"_a || o == "read"_a || o == "readonly"_a) dm |= ReadOnly;
|
||||
if (o == "w"_a || o == "wo"_a || o == "write"_a || o == "writeonly"_a) dm |= WriteOnly;
|
||||
@@ -666,7 +667,7 @@ PIMap<PIConstChars, PIIODevice::FabricInfo> & PIIODevice::fabrics() {
|
||||
|
||||
|
||||
bool PIIODevice::threadedRead(const uchar * readed, ssize_t size) {
|
||||
// piCout << "iodevice threaded read";
|
||||
// piCout << "iodevice threaded read";
|
||||
if (func_read) return func_read(readed, size, ret_data_);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "piiostring.h"
|
||||
|
||||
#include "pitranslator.h"
|
||||
|
||||
|
||||
//! \class PIIOString piiostring.h
|
||||
//! \details
|
||||
@@ -49,7 +51,7 @@ void PIIOString::clear() {
|
||||
|
||||
bool PIIOString::open(PIString * string, PIIODevice::DeviceMode mode) {
|
||||
if (mode == PIIODevice::ReadWrite) {
|
||||
piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly";
|
||||
piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly"_tr("PIIOString");
|
||||
str = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "piincludes_p.h"
|
||||
#include "pipropertystorage.h"
|
||||
#include "pitime.h"
|
||||
#include "pitranslator.h"
|
||||
#include "piwaitevent_p.h"
|
||||
|
||||
#include <errno.h>
|
||||
@@ -463,10 +464,10 @@ int PISerial::convertSpeed(PISerial::Speed speed) {
|
||||
default: break;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
piCoutObj << "Warning: Custom speed" << (int)speed;
|
||||
piCoutObj << "Warning: Custom speed %1"_tr("PISerial").arg((int)speed);
|
||||
return (int)speed;
|
||||
#else
|
||||
piCoutObj << "Warning: Unknown speed" << (int)speed << ", using 115200";
|
||||
piCoutObj << "Warning: Unknown speed %1, using 115200"_tr("PISerial").arg((int)speed);
|
||||
return B115200;
|
||||
#endif
|
||||
}
|
||||
@@ -691,7 +692,7 @@ bool PISerial::openDevice() {
|
||||
}
|
||||
}
|
||||
if (p.isEmpty()) {
|
||||
piCoutObj << "Unable to find device \"" << pl << "\"";
|
||||
piCoutObj << "Unable to find device \"%1\""_tr("PISerial").arg(pl);
|
||||
}
|
||||
}
|
||||
if (p.isEmpty()) return false;
|
||||
@@ -708,7 +709,7 @@ bool PISerial::openDevice() {
|
||||
PIString wp = "//./" + p;
|
||||
PRIVATE->hCom = CreateFileA(wp.dataAscii(), ds, sm, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0);
|
||||
if (PRIVATE->hCom == INVALID_HANDLE_VALUE) {
|
||||
piCoutObj << "Unable to open \"" << p << "\"" << errorString();
|
||||
piCoutObj << "Unable to open \"%1\": %2"_tr("PISerial").arg(p).arg(errorString());
|
||||
fd = -1;
|
||||
return false;
|
||||
}
|
||||
@@ -722,7 +723,7 @@ bool PISerial::openDevice() {
|
||||
}
|
||||
fd = ::open(p.data(), O_NOCTTY | om);
|
||||
if (fd == -1) {
|
||||
piCoutObj << "Unable to open \"" << p << "\"";
|
||||
piCoutObj << "Unable to open \"%1\": %2"_tr("PISerial").arg(p).arg(errorString());
|
||||
return false;
|
||||
}
|
||||
tcgetattr(fd, &PRIVATE->desc);
|
||||
@@ -747,7 +748,7 @@ bool PISerial::closeDevice() {
|
||||
#ifdef WINDOWS
|
||||
SetCommState(PRIVATE->hCom, &PRIVATE->sdesc);
|
||||
SetCommMask(PRIVATE->hCom, PRIVATE->mask);
|
||||
// piCoutObj << "close" <<
|
||||
// piCoutObj << "close" <<
|
||||
CloseHandle(PRIVATE->hCom);
|
||||
PRIVATE->hCom = 0;
|
||||
#else
|
||||
@@ -788,7 +789,7 @@ void PISerial::applySettings() {
|
||||
}
|
||||
PRIVATE->desc.StopBits = params[PISerial::TwoStopBits] ? TWOSTOPBITS : ONESTOPBIT;
|
||||
if (SetCommState(PRIVATE->hCom, &PRIVATE->desc) == -1) {
|
||||
piCoutObj << "Unable to set comm state for \"" << path() << "\"";
|
||||
piCoutObj << "Unable to set comm state for \"%1\""_tr("PISerial").arg(path());
|
||||
return;
|
||||
}
|
||||
#else
|
||||
@@ -822,7 +823,7 @@ void PISerial::applySettings() {
|
||||
setTimeouts();
|
||||
|
||||
if (tcsetattr(fd, TCSANOW, &PRIVATE->desc) < 0) {
|
||||
piCoutObj << "Can`t set attributes for \"" << path() << "\"";
|
||||
piCoutObj << "Can`t set attributes for \"%1\""_tr("PISerial").arg(path());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -871,7 +872,7 @@ ssize_t PISerial::readDevice(void * read_to, ssize_t max_size) {
|
||||
// piCoutObj << "read ..." << PRIVATE->hCom << max_size;
|
||||
DWORD mask = 0;
|
||||
if (GetCommMask(PRIVATE->hCom, &mask) == FALSE) {
|
||||
piCoutObj << "read error" << errorString();
|
||||
piCoutObj << "Read error: %1"_tr("PISerial").arg(errorString());
|
||||
stop();
|
||||
close();
|
||||
return 0;
|
||||
@@ -883,7 +884,7 @@ ssize_t PISerial::readDevice(void * read_to, ssize_t max_size) {
|
||||
DWORD err = GetLastError();
|
||||
// piCoutObj << "read" << err;
|
||||
if (err == ERROR_BAD_COMMAND || err == ERROR_ACCESS_DENIED) {
|
||||
piCoutObj << "read error" << errorString();
|
||||
piCoutObj << "Read error: %1"_tr("PISerial").arg(errorString());
|
||||
stop();
|
||||
close();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user