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
GitLab 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
No related branches found
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:
...
@@ -95,6 +95,9 @@ else:
print
((
'
ERROR. Unknown device type
'
+
str
(
config
.
_device_type
)))
print
((
'
ERROR. Unknown device type
'
+
str
(
config
.
_device_type
)))
exit
(
0
)
exit
(
0
)
if
mydevice
.
addr
==
None
:
print
(
'
ERROR: no device found for reading data
'
)
exit
(
1
)
def
loop
():
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):
...
@@ -468,6 +468,7 @@ class SQMLE(SQM):
except
:
except
:
print
(
'
Trying auto device address ...
'
)
print
(
'
Trying auto device address ...
'
)
self
.
addr
=
self
.
search
()
self
.
addr
=
self
.
search
()
if
self
.
addr
!=
None
:
print
((
'
Found address %s ...
'
%
str
(
self
.
addr
)))
print
((
'
Found address %s ...
'
%
str
(
self
.
addr
)))
self
.
port
=
10001
self
.
port
=
10001
self
.
start_connection
()
self
.
start_connection
()
...
@@ -667,14 +668,20 @@ class SQMLU(SQM):
...
@@ -667,14 +668,20 @@ class SQMLU(SQM):
print
((
'
Trying fixed device address %s ...
'
%
str
(
config
.
_device_addr
)))
print
((
'
Trying fixed device address %s ...
'
%
str
(
config
.
_device_addr
)))
self
.
addr
=
config
.
_device_addr
self
.
addr
=
config
.
_device_addr
self
.
bauds
=
115200
self
.
bauds
=
115200
try
:
self
.
start_connection
()
self
.
start_connection
()
except
OSError
:
print
(
'
device
'
,
config
.
_device_addr
,
'
does not exist
'
)
raise
except
:
except
:
print
(
'
Trying auto device address ...
'
)
print
(
'
Trying auto device address ...
'
)
self
.
addr
=
self
.
search
()
self
.
addr
=
self
.
search
()
if
self
.
addr
!=
None
:
print
((
'
Found address %s ...
'
%
str
(
self
.
addr
)))
print
((
'
Found address %s ...
'
%
str
(
self
.
addr
)))
if
self
.
addr
!=
None
:
self
.
bauds
=
115200
self
.
bauds
=
115200
self
.
start_connection
()
self
.
start_connection
()
# Clearing buffer
# Clearing buffer
print
((
'
Clearing buffer ... |
'
),
end
=
'
'
)
print
((
'
Clearing buffer ... |
'
),
end
=
'
'
)
buffer_data
=
self
.
read_buffer
()
buffer_data
=
self
.
read_buffer
()
...
@@ -700,26 +707,34 @@ class SQMLU(SQM):
...
@@ -700,26 +707,34 @@ class SQMLU(SQM):
os_in_use
=
sys
.
platform
os_in_use
=
sys
.
platform
if
os_in_use
==
'
linux2
'
:
if
os_in_use
==
'
linux2
'
:
print
(
'
Detected Linux2 platform
'
)
ports
=
ports_unix
elif
os_in_use
==
'
linux
'
:
print
(
'
Detected Linux platform
'
)
print
(
'
Detected Linux platform
'
)
ports
=
ports_unix
ports
=
ports_unix
elif
os_in_use
==
'
win32
'
:
elif
os_in_use
==
'
win32
'
:
print
(
'
Detected Windows platform
'
)
print
(
'
Detected Windows platform
'
)
ports
=
ports_win
ports
=
ports_win
else
:
print
(
'
No supported platform detected ->
'
,
os_in_use
)
used_port
=
None
used_port
=
None
for
port
in
ports
:
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
=
serial
.
Serial
(
port
,
115200
,
timeout
=
1
)
conn_test
.
write
(
'
ix
'
.
encode
)
conn_test
.
write
(
'
ix
'
.
encode
)
if
conn_test
.
readline
()[
0
]
==
'
i
'
:
if
conn_test
.
readline
()[
0
]
==
'
i
'
:
used_port
=
port
used_port
=
port
break
break
try
:
if
(
used_port
==
None
):
assert
(
used_port
!=
None
)
except
:
print
(
'
ERR. Device not found!
'
)
print
(
'
ERR. Device not found!
'
)
raise
else
:
return
(
used_port
)
return
(
used_port
)
def
start_connection
(
self
):
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