Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DSerial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
apps
DSerial
Commits
e124698b
Commit
e124698b
authored
9 years ago
by
Isabella Skořepová
Browse files
Options
Downloads
Patches
Plain Diff
Make test port appear in list and change name to path
parent
f9faaa79
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dserial-server/controller.cpp
+3
-3
3 additions, 3 deletions
dserial-server/controller.cpp
dserial-server/port.cpp
+14
-11
14 additions, 11 deletions
dserial-server/port.cpp
dserial-server/port.h
+1
-0
1 addition, 0 deletions
dserial-server/port.h
with
18 additions
and
14 deletions
dserial-server/controller.cpp
+
3
−
3
View file @
e124698b
...
...
@@ -9,6 +9,7 @@ Controller::Controller(QObject *parent) : QObject(parent), connection(QDBusConne
new
PortAdaptor
(
port
);
port
->
dbusPath
.
setPath
(
"/fake/test0"
);
connection
.
registerObject
(
port
->
dbusPath
.
path
(),
port
);
ports
.
append
(
port
);
}
QStringList
Controller
::
PortList
()
const
...
...
@@ -43,11 +44,10 @@ void Controller::Autodetect()
// Detect new
for
(
QSerialPortInfo
info
:
QSerialPortInfo
::
availablePorts
())
{
qDebug
()
<<
info
.
portName
();
qDebug
()
<<
info
.
systemLocation
();
bool
isInList
=
false
;
for
(
Port
*
port
:
ports
)
{
qDebug
()
<<
port
->
Name
();
if
(
info
.
portName
()
==
port
->
Name
())
{
if
(
info
.
systemLocation
()
==
port
->
Name
())
{
isInList
=
true
;
break
;
}
...
...
This diff is collapsed.
Click to expand it.
dserial-server/port.cpp
+
14
−
11
View file @
e124698b
...
...
@@ -9,6 +9,7 @@
Port
::
Port
(
QString
name
,
quint8
type
,
QObject
*
parent
)
:
QObject
(
parent
),
closeTimer
(),
autoCloseTimer
(),
readTimer
(),
serialPort
(
name
)
{
this
->
name
=
name
;
this
->
type
=
type
;
closeTimer
.
setInterval
(
5000
);
closeTimer
.
setSingleShot
(
true
);
...
...
@@ -32,7 +33,7 @@ Port::Port(QString name, quint8 type, QObject *parent) : QObject(parent), closeT
QString
Port
::
Name
()
const
{
if
(
!
Exists
())
return
QString
(
"REMOVED"
);
return
serialPort
.
portN
ame
()
;
return
n
ame
;
}
qint32
Port
::
Baudrate
()
const
...
...
@@ -87,18 +88,20 @@ void Port::Write(QByteArray data)
debugWrite
.
append
(
QString
::
number
(
byte
,
16
));
}
qDebug
().
nospace
().
noquote
()
<<
debugWrite
;
if
(
!
serialPort
.
isOpen
())
{
if
(
serialPort
.
open
(
QSerialPort
::
WriteOnly
))
{
qDebug
()
<<
" Autoopened port"
;
qDebug
()
<<
" Wrote"
<<
serialPort
.
write
(
data
)
<<
"bytes"
;
serialPort
.
flush
();
serialPort
.
close
();
qDebug
()
<<
" Port was closed"
;
if
(
type
==
0
)
{
if
(
!
serialPort
.
isOpen
())
{
if
(
serialPort
.
open
(
QSerialPort
::
WriteOnly
))
{
qDebug
()
<<
" Autoopened port"
;
qDebug
()
<<
" Wrote"
<<
serialPort
.
write
(
data
)
<<
"bytes"
;
serialPort
.
flush
();
serialPort
.
close
();
qDebug
()
<<
" Port was closed"
;
}
else
{
qDebug
().
nospace
().
noquote
()
<<
" Port autoopen failed ("
<<
errorString
()
<<
") - no data written"
;
}
}
else
{
qDebug
()
.
nospace
().
noquote
()
<<
" Port autoopen failed (
"
<<
er
rorString
()
<<
") - no data writ
te
n
"
;
qDebug
()
<<
" Wrote
"
<<
s
er
ialPort
.
write
(
data
)
<<
"by
te
s
"
;
}
}
else
{
qDebug
()
<<
" Wrote"
<<
serialPort
.
write
(
data
)
<<
"bytes"
;
}
emit
DataSent
(
data
);
}
...
...
This diff is collapsed.
Click to expand it.
dserial-server/port.h
+
1
−
0
View file @
e124698b
...
...
@@ -67,6 +67,7 @@ class Port : public QObject
void
read
();
private:
QString
name
;
quint8
type
;
void
notifyPropertyChanged
(
const
char
*
propertyName
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment