Socket connection refused (F7 fingerprint reader)

Socket connection refused (F7 fingerprint reader)

Postby AndresFelix » Fri Apr 25, 2014 7:44 am

Hello, I'm having some trouble with a school project. I'm trying to read whatever a device (F7 fingerprint reader) is sending and write it in a text document. The objective is to communicate with the F7 in a local network. I'm using a router as a switch. I configured the F7's Comm Settings (IP addr: 192.168.1.160, Mask: 255.255.255.0, Default Gateway: 192.168.1.254) and I run a python code in my computer that it is supposed to retrieve the data sent by the F7 and write on the text document.
I know that the default port used by the F7 is port 4370, I'm trying to connect to it by creating a socket IP + Port, since I know both.

This is my code:
Code: Select all
    import socket
    import sys
    TCP_IP = '192.168.1.160'
    TCP_PORT = 4370
    errormsg = 'No connection created'
    succmsg = 'Connection created'
    try:
        soc = socket.socket()
        soc.connect((TCP_IP, TCP_PORT))
    except socket.error:
        print (errormsg)
        input("Press ENTER to exit")
        sys.exit()
    print (succmsg)
    while True:
       msg = soc.recv(1024)
       msg = str(msg)
       print (msg)
       with open('BiometricID.txt','a') as f:
          f.write(msg)
          f.write('\n')
    soc.close()
    input("Press ENTER to exit")


I thought that code could work but it throws an error "10061", that says that the machine actively refused the connection. It is quite possible that I have other mistakes, but first I want to connect to the device, after that I'll go on with whatever could fail too.
If you need more information just ask and I'll try to provide it.
Thank you very much!
AndresFelix
 
Posts: 1
Joined: Fri Apr 25, 2014 7:38 am

Return to Networking

Who is online

Users browsing this forum: No registered users and 3 guests