Python Forum
Sockets interferring with USB ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sockets interferring with USB ?
#1
I've written a program to create a server socket to interface with an embedded client socket in a program (stellarium) running on the same PC. Works great, I can receive and send data to stellarium. But I also want to read and process data from an arduino retrieved from the arduino via the USB. But the socket software seems to prevent reading the USB. The server routine continues to interface with stellarium but I can't read the arduino from the USB. I tried myserver_socket.setblocking(0) but no luck. Am I going to have to learn threading? The "?" highlighted block does not work even after the server receives data. Argh
Thanks
Mark

open_sockets = []

pc2Stell_socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
pc2Stell_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

# Configure Stellarium telescope control to use "localhost" and
# port 10001 (client port and name)

pc2Stell_socket.bind( ("localhost", 10001) )
pc2Stell_socket.setblocking(0) # doesn't help !!!
pc2Stell_socket.listen(5)
print(pc2Stell_socket.getblocking())

ser = serial.Serial('COM6',9600) # pick up data from arduino.

while true:
rlist, wlist, xlist = select.select( [pc2Stell_socket] + open_sockets, [], [] )

print("==============================================================")
# iterate on rlist once the read event occurs
print("done waiting")
for i in rlist:
? arduinoCoords = ser.readline()
? if(arduinoCoords[0]==97):
? TeleAz = arduinoCoords[2:-2]
? if(arduinoCoords[0]==98):
? TeleElev = arduinoCoords[2:-2]

? print(float(TeleAz), float(TeleElev))
if i is pc2Stell_socket:
# at this point i becomes a socket object. See the i.send() and i.recv()
new_socket, addr = pc2Stell_socket.accept()
open_sockets.append(new_socket)
print("Connected")
etc. ******************
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Just learning sockets etc... floatingshed 2 2,294 May-06-2020, 09:37 PM
Last Post: floatingshed
  Quick sockets question... ptrivino 2 2,175 Sep-26-2019, 08:51 PM
Last Post: ptrivino
  Sockets and Sendmail taintedsushi 2 2,304 Sep-02-2019, 12:51 PM
Last Post: venquessa
  Script Conversion 2.7 to 3 (sockets) Pumpernickel 1 2,514 Apr-10-2019, 04:26 PM
Last Post: Pumpernickel
  What sort of things can I write to learn about sockets marienbad 2 2,664 Oct-16-2018, 04:02 PM
Last Post: buran
  unix domain sockets Skaperen 8 4,844 Sep-02-2018, 07:02 PM
Last Post: Skaperen
  file transfer with sockets sinister88 1 6,417 Nov-11-2017, 03:29 PM
Last Post: heiner55
  Trouble with sending raw sockets IronReign 2 4,170 Jun-01-2017, 08:26 AM
Last Post: camp0
  Silly Sockets Jarvis 2 4,179 Feb-20-2017, 01:43 PM
Last Post: Jarvis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020