Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySQM Darkersky4CE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Dario Barghini
PySQM Darkersky4CE
Commits
8b367822
Commit
8b367822
authored
2 years ago
by
Thorsten Alteholz
Browse files
Options
Downloads
Patches
Plain Diff
add some error handling
parent
921632f1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pysqm/main.py
+3
-0
3 additions, 0 deletions
pysqm/main.py
pysqm/read.py
+39
-24
39 additions, 24 deletions
pysqm/read.py
with
42 additions
and
24 deletions
pysqm/main.py
+
3
−
0
View file @
8b367822
...
...
@@ -95,6 +95,9 @@ else:
print
((
'
ERROR. Unknown device type
'
+
str
(
config
.
_device_type
)))
exit
(
0
)
if
mydevice
.
addr
==
None
:
print
(
'
ERROR: no device found for reading data
'
)
exit
(
1
)
def
loop
():
'''
...
...
This diff is collapsed.
Click to expand it.
pysqm/read.py
+
39
−
24
View file @
8b367822
...
...
@@ -468,6 +468,7 @@ class SQMLE(SQM):
except
:
print
(
'
Trying auto device address ...
'
)
self
.
addr
=
self
.
search
()
if
self
.
addr
!=
None
:
print
((
'
Found address %s ...
'
%
str
(
self
.
addr
)))
self
.
port
=
10001
self
.
start_connection
()
...
...
@@ -667,14 +668,20 @@ class SQMLU(SQM):
print
((
'
Trying fixed device address %s ...
'
%
str
(
config
.
_device_addr
)))
self
.
addr
=
config
.
_device_addr
self
.
bauds
=
115200
try
:
self
.
start_connection
()
except
OSError
:
print
(
'
device
'
,
config
.
_device_addr
,
'
does not exist
'
)
raise
except
:
print
(
'
Trying auto device address ...
'
)
self
.
addr
=
self
.
search
()
if
self
.
addr
!=
None
:
print
((
'
Found address %s ...
'
%
str
(
self
.
addr
)))
if
self
.
addr
!=
None
:
self
.
bauds
=
115200
self
.
start_connection
()
# Clearing buffer
print
((
'
Clearing buffer ... |
'
),
end
=
'
'
)
buffer_data
=
self
.
read_buffer
()
...
...
@@ -700,26 +707,34 @@ class SQMLU(SQM):
os_in_use
=
sys
.
platform
if
os_in_use
==
'
linux2
'
:
print
(
'
Detected Linux2 platform
'
)
ports
=
ports_unix
elif
os_in_use
==
'
linux
'
:
print
(
'
Detected Linux platform
'
)
ports
=
ports_unix
elif
os_in_use
==
'
win32
'
:
print
(
'
Detected Windows platform
'
)
ports
=
ports_win
else
:
print
(
'
No supported platform detected ->
'
,
os_in_use
)
used_port
=
None
for
port
in
ports
:
try
:
os
.
stat
(
port
)
except
OSError
:
print
(
'
port
'
,
port
,
'
does not exist
'
)
continue
conn_test
=
serial
.
Serial
(
port
,
115200
,
timeout
=
1
)
conn_test
.
write
(
'
ix
'
.
encode
)
if
conn_test
.
readline
()[
0
]
==
'
i
'
:
used_port
=
port
break
try
:
assert
(
used_port
!=
None
)
except
:
if
(
used_port
==
None
):
print
(
'
ERR. Device not found!
'
)
raise
else
:
return
(
used_port
)
def
start_connection
(
self
):
...
...
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