Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
AgriTech
Mobile Autonomous Cart with guided Vision for Agriculture
Commits
56f5c907
Commit
56f5c907
authored
Jul 17, 2021
by
Shrishailya Agashe
Browse files
Upload New File
parent
f6836de0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Arduino - Python Communication/main.py
0 → 100644
View file @
56f5c907
# This code accepts incoming string from the COM Port, Parses the JSON String and converts it into a dictionary.
# The final dictionary object JSONDict is created.
# I have simply printed the dictionary here.
# The code can be modified to do required opeartions on the dictionary.
# - Shrishailya Agashe
import
json
import
serial
#replace this with the comport of your arduino
comport
=
'COM3'
#initialize the serial object
myArduino
=
serial
.
Serial
(
port
=
comport
,
baudrate
=
115200
,
timeout
=
1
)
#infinite loop that checks continuously for incoming JSON string
while
True
:
try
:
incoming_stream
=
myArduino
.
readline
()
#incoming_stream = incoming_stream.decode('utf-8')
incoming_stream
=
incoming_stream
.
strip
()
print
(
incoming_stream
)
except
:
print
(
"keyboard Interrupt"
)
break
Write
Preview
Supports
Markdown
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