-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial native iOS analog joysticks (Swift), added basic serial…
… comm in python * Basic analog joysticks in iOS using a Swift library * Added basic serial communication in Python 3 * Updated to MQTT scripts for Python 3 * Updated esp8266 MQTT code
- Loading branch information
1 parent
a34cb23
commit ed76336
Showing
38 changed files
with
2,729 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#! /usr/bin/env python | ||
|
||
############################################################################### | ||
# basic_serial_communication.py | ||
# | ||
# script to achieve basic send/receive communication | ||
# | ||
# NOTE: Any plotting is set up for output, not viewing on screen. | ||
# So, it will likely be ugly on screen. The saved PDFs should look | ||
# better. | ||
# | ||
# Created: 05/27/16 | ||
# - Joshua Vaughan | ||
# - [email protected] | ||
# - http://www.ucs.louisiana.edu/~jev9637 | ||
# | ||
# Modified: | ||
# * | ||
# | ||
############################################################################### | ||
|
||
import numpy as np | ||
import logging | ||
import serial | ||
import time | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# TODO: Make a nice class-based serial object for easier reuse | ||
# class serial_comm(object): | ||
# ''' Class for sending/receiving serial data''' | ||
# def __init__(self, port): | ||
# self.port = port | ||
# self.ser = serial.Serial(port, 115200) | ||
# | ||
# # Sends throttle and steering angle commands to platform | ||
# def send_string(self, string): | ||
# | ||
# if type(string) is str: | ||
# # Write the data to the serial connection - to the Arudino for CAN bus formatting | ||
# self.ser.write(str(string)) | ||
# else: | ||
# logging.debug('The send_string method requires a str type argument.') | ||
# | ||
# def __del__(self): | ||
# self.ser.close() | ||
# | ||
|
||
if __name__ == '__main__': | ||
# serial port will have to change based on configuration | ||
PORT = '/dev/tty.usbserial-A6001Ko5' | ||
|
||
# define the serial communication parameters, 8 bits, no parity, 1 stop bit | ||
BPS = 115200 | ||
|
||
ser = serial.Serial(PORT, BPS) | ||
|
||
time_start = time.time() | ||
|
||
try: | ||
while True: | ||
dt = time.time() - time_start | ||
|
||
data = 100 * np.sin(0.5*np.pi * dt) | ||
|
||
data_string = '{}\r\n'.format(int(data)).encode('utf-8') | ||
|
||
ser.write(data_string) | ||
print(data_string) | ||
|
||
time.sleep(0.05) | ||
|
||
|
||
except (KeyboardInterrupt, SystemExit): | ||
ser.close() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.