
import serial
import socket
import time

arduino_dist = serial.Serial('/dev/ttyUSB0',9600)

def get_distance():
	distance = arduino_dist.readline()
	return distance

class Client(object):
	"""A class that uses sockets to connect to a server"""
	HOST = "userinterface.local"
	PORT = 12345
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	
	def socket_connection(self):
		Client.s.connect((Client.HOST, Client.PORT))
	
	def receive_data(self):
		data = Client.s.recv(4096)
		return data
	
	def send_data(self, data):
		Client.s.send(data)

client = Client()
client.socket_connection()
while True:
	client.send_data("Hello! Yo!")
	time.sleep(1)


import serial
import socket
import time
import sys
sys.path.insert(0, "/home/pi/lidar/pi_approach/Libraries")
import serverxclient

arduino_dist = serial.Serial('/dev/ttyUSB0',9600)

def get_distance():
	distance = arduino_dist.readline()
	return distance

client = Client()
client.socket_connection()
while True:
	client.send_data("Hello! Yo!")
	time.sleep(1)

Remove local use of client, instead rely on imported library
Remove local use of client, instead rely on imported library

  
  import serial
  import socket
  import time
+ import sys
+ sys.path.insert(0, "/home/pi/lidar/pi_approach/Libraries")
+ import serverxclient
  
  arduino_dist = serial.Serial('/dev/ttyUSB0',9600)
  
  def get_distance():
  	distance = arduino_dist.readline()
  	return distance
  
- class Client(object):
- 	"""A class that uses sockets to connect to a server"""
- 	HOST = "userinterface.local"
- 	PORT = 12345
- 	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- 	
- 	def socket_connection(self):
- 		Client.s.connect((Client.HOST, Client.PORT))
- 	
- 	def receive_data(self):
- 		data = Client.s.recv(4096)
- 		return data
- 	
- 	def send_data(self, data):
- 		Client.s.send(data)
- 
  client = Client()
  client.socket_connection()
  while True:
  	client.send_data("Hello! Yo!")
  	time.sleep(1)
  
Remove local use of client, instead rely on imported library
## Code Before:

import serial
import socket
import time

arduino_dist = serial.Serial('/dev/ttyUSB0',9600)

def get_distance():
	distance = arduino_dist.readline()
	return distance

class Client(object):
	"""A class that uses sockets to connect to a server"""
	HOST = "userinterface.local"
	PORT = 12345
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	
	def socket_connection(self):
		Client.s.connect((Client.HOST, Client.PORT))
	
	def receive_data(self):
		data = Client.s.recv(4096)
		return data
	
	def send_data(self, data):
		Client.s.send(data)

client = Client()
client.socket_connection()
while True:
	client.send_data("Hello! Yo!")
	time.sleep(1)

## Instruction:
Remove local use of client, instead rely on imported library
## Code After:

import serial
import socket
import time
import sys
sys.path.insert(0, "/home/pi/lidar/pi_approach/Libraries")
import serverxclient

arduino_dist = serial.Serial('/dev/ttyUSB0',9600)

def get_distance():
	distance = arduino_dist.readline()
	return distance

client = Client()
client.socket_connection()
while True:
	client.send_data("Hello! Yo!")
	time.sleep(1)
