Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
5b50c4fb
Commit
5b50c4fb
authored
Mar 17, 2011
by
Friedemann Kleint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Symbian: Polish messages related to CODA-ports.
parent
1585e61c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
15 deletions
+28
-15
src/shared/symbianutils/virtualserialdevice_posix.cpp
src/shared/symbianutils/virtualserialdevice_posix.cpp
+12
-6
src/shared/symbianutils/virtualserialdevice_win.cpp
src/shared/symbianutils/virtualserialdevice_win.cpp
+16
-9
No files found.
src/shared/symbianutils/virtualserialdevice_posix.cpp
View file @
5b50c4fb
...
...
@@ -68,13 +68,15 @@ bool VirtualSerialDevice::open(OpenMode mode)
d
->
portHandle
=
::
open
(
portName
.
toAscii
().
constData
(),
O_RDWR
|
O_NONBLOCK
|
O_NOCTTY
);
if
(
d
->
portHandle
==
-
1
)
{
setErrorString
(
QString
(
"Posix error %1 opening %2"
).
arg
(
errno
).
arg
(
portName
));
setErrorString
(
tr
(
"The port %1 could not be opened: %2 (POSIX error %3)"
).
arg
(
portName
,
QString
::
fromLocal8Bit
(
strerror
(
errno
))).
arg
(
errno
));
return
false
;
}
struct
termios
termInfo
;
if
(
tcgetattr
(
d
->
portHandle
,
&
termInfo
)
<
0
)
{
setErrorString
(
QString
::
fromLatin1
(
"Unable to retrieve terminal settings: %1 %2"
).
arg
(
errno
).
arg
(
QString
::
fromAscii
(
strerror
(
errno
))));
setErrorString
(
tr
(
"Unable to retrieve terminal settings of port %1: %2 (POSIX error %3)"
).
arg
(
portName
,
QString
::
fromLocal8Bit
(
strerror
(
errno
))).
arg
(
errno
));
close
();
return
false
;
}
...
...
@@ -93,7 +95,8 @@ bool VirtualSerialDevice::open(OpenMode mode)
termInfo
.
c_cc
[
VSUSP
]
=
_POSIX_VDISABLE
;
if
(
tcsetattr
(
d
->
portHandle
,
TCSAFLUSH
,
&
termInfo
)
<
0
)
{
setErrorString
(
QString
::
fromLatin1
(
"Unable to apply terminal settings: %1 %2"
).
arg
(
errno
).
arg
(
QString
::
fromAscii
(
strerror
(
errno
))));
setErrorString
(
tr
(
"Unable to apply terminal settings to port %1: %2 (POSIX error %3)"
).
arg
(
portName
,
QString
::
fromLocal8Bit
(
strerror
(
errno
))).
arg
(
errno
));
close
();
return
false
;
}
...
...
@@ -189,12 +192,14 @@ bool VirtualSerialDevice::tryWrite(const char *data, qint64 maxSize, qint64& byt
if
(
result
==
-
1
)
{
if
(
errno
==
EAGAIN
)
return
true
;
// Need to wait
setErrorString
(
QString
(
"Posix error %1 from write to %2"
).
arg
(
errno
).
arg
(
portName
));
setErrorString
(
tr
(
"Cannot write to port %1: %2 (POSIX error %3)"
).
arg
(
portName
,
QString
::
fromLocal8Bit
(
strerror
(
errno
))).
arg
(
errno
));
bytesWritten
=
-
1
;
return
false
;
}
else
{
if
(
result
==
0
)
qWarning
(
"Zero bytes written to port
!"
);
qWarning
(
"
%s:
Zero bytes written to port
%s!"
,
Q_FUNC_INFO
,
qPrintable
(
portName
)
);
bytesWritten
+=
result
;
maxSize
-=
result
;
data
+=
result
;
...
...
@@ -303,7 +308,8 @@ bool VirtualSerialDevice::waitForBytesWritten(int msecs)
// Timeout
return
false
;
}
else
if
(
ret
<
0
)
{
setErrorString
(
QString
(
"Posix error %1 returned from select in waitForBytesWritten"
).
arg
(
errno
));
setErrorString
(
tr
(
"The function select() returned an error on port %1: %2 (POSIX error %3)"
).
arg
(
portName
,
QString
::
fromLocal8Bit
(
strerror
(
errno
))).
arg
(
errno
));
return
false
;
}
else
{
bool
needToWait
=
tryFlushPendingBuffers
(
locker
,
StopAfterWritingOneBuffer
);
...
...
src/shared/symbianutils/virtualserialdevice_win.cpp
View file @
5b50c4fb
...
...
@@ -64,7 +64,7 @@ QString windowsPortName(const QString& port)
{
// Add the \\.\ to the name if it's a COM port and doesn't already have it
QString
winPortName
(
port
);
if
(
winPortName
.
startsWith
(
"COM"
))
{
if
(
winPortName
.
startsWith
(
QLatin1String
(
"COM"
))
)
{
winPortName
.
prepend
(
"
\\\\
.
\\
"
);
}
return
winPortName
;
...
...
@@ -112,7 +112,8 @@ bool VirtualSerialDevice::open(OpenMode mode)
d
->
portHandle
=
CreateFileA
(
windowsPortName
(
portName
).
toAscii
(),
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_OVERLAPPED
,
NULL
);
if
(
d
->
portHandle
==
INVALID_HANDLE_VALUE
)
{
setErrorString
(
winErrorMessage
(
GetLastError
()));
setErrorString
(
tr
(
"The port %1 could not be opened: %2"
).
arg
(
portName
,
winErrorMessage
(
GetLastError
())));
return
false
;
}
...
...
@@ -162,13 +163,14 @@ bool VirtualSerialDevice::open(OpenMode mode)
if
(
!
SetCommMask
(
d
->
portHandle
,
EV_RXCHAR
))
{
// What to do?
qWarning
(
"Could
n'
t set comm mask, err=%d"
,
(
int
)
GetLastError
());
qWarning
(
"
%s:
Could
no
t set comm mask, err=%d"
,
Q_FUNC_INFO
,
(
int
)
GetLastError
());
}
bool
result
=
WaitCommEvent
(
d
->
portHandle
,
&
d
->
commEventMask
,
&
d
->
commEventOverlapped
);
Q_ASSERT
(
result
==
false
);
// Can't see how it would make sense to be anything else...
(
void
)
result
;
// For release build
if
(
GetLastError
()
!=
ERROR_IO_PENDING
)
{
setErrorString
(
QString
(
"%1 waiting for read notifications from %2"
).
arg
(
winErrorMessage
(
GetLastError
())).
arg
(
portName
));
setErrorString
(
tr
(
"An error occurred while waiting for read notifications from %1: %2"
).
arg
(
portName
,
winErrorMessage
(
GetLastError
())));
close
();
return
false
;
}
...
...
@@ -239,7 +241,8 @@ qint64 VirtualSerialDevice::readData(char *data, qint64 maxSize)
}
// If we reach here an error has occurred
setErrorString
(
QString
(
"%1 reading from %2"
).
arg
(
winErrorMessage
(
GetLastError
())).
arg
(
portName
));
setErrorString
(
tr
(
"An error occurred while reading from %1: %2"
).
arg
(
portName
,
winErrorMessage
(
GetLastError
())));
return
-
1
;
}
...
...
@@ -270,7 +273,8 @@ qint64 VirtualSerialDevice::writeNextBuffer(QMutexLocker& locker)
return
bufLen
;
}
else
{
setErrorString
(
QString
(
"%1 writing to %2"
).
arg
(
winErrorMessage
(
GetLastError
())).
arg
(
portName
));
setErrorString
(
tr
(
"An error occurred while writing to %1: %2"
).
arg
(
portName
,
winErrorMessage
(
GetLastError
())));
pendingWrites
.
removeFirst
();
return
-
1
;
}
...
...
@@ -280,7 +284,8 @@ void VirtualSerialDevice::writeCompleted()
{
QMutexLocker
locker
(
&
lock
);
if
(
pendingWrites
.
count
()
==
0
)
{
qWarning
(
"writeCompleted called when there are no pending writes!"
);
qWarning
(
"%s: writeCompleted called when there are no pending writes on %s!"
,
Q_FUNC_INFO
,
qPrintable
(
portName
));
return
;
}
...
...
@@ -327,7 +332,8 @@ bool VirtualSerialDevice::waitForBytesWritten(int msecs)
DWORD
bytesWritten
;
BOOL
ok
=
GetOverlappedResult
(
d
->
portHandle
,
&
d
->
writeOverlapped
,
&
bytesWritten
,
TRUE
);
if
(
!
ok
)
{
setErrorString
(
QString
(
"%1 syncing on waitForBytesWritten for %2"
).
arg
(
winErrorMessage
(
GetLastError
())).
arg
(
portName
));
setErrorString
(
tr
(
"An error occurred while syncing on waitForBytesWritten for %1: %2"
).
arg
(
portName
,
winErrorMessage
(
GetLastError
())));
return
false
;
}
Q_ASSERT
(
bytesWritten
==
(
DWORD
)
pendingWrites
.
first
().
length
());
...
...
@@ -336,7 +342,8 @@ bool VirtualSerialDevice::waitForBytesWritten(int msecs)
return
true
;
}
else
{
setErrorString
(
QString
(
"%1 in waitForBytesWritten for %2"
).
arg
(
winErrorMessage
(
GetLastError
())).
arg
(
portName
));
setErrorString
(
QString
(
"An error occured in waitForBytesWritten() for %1: %2"
).
arg
(
portName
,
winErrorMessage
(
GetLastError
())));
return
false
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment