Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBD Not Connecting MacOS #261

Open
davibenica opened this issue Jun 6, 2023 · 0 comments
Open

OBD Not Connecting MacOS #261

davibenica opened this issue Jun 6, 2023 · 0 comments

Comments

@davibenica
Copy link

Enviroment:
OBDII ELM327 v1.5
MacOS 12.1 Montery
Python 3.11
python-OBD v0.7.1

I am encountering an issue with connecting to an OBD-II reader on macOS using the python-OBD library. I have followed the documentation and attempted to establish a Bluetooth connection, but I'm unable to retrieve any data from the OBD-II device.

When trying to connect using a specific baud rate(38400)

[obd.obd] ======================= python-OBD (v0.7.1) =======================
[obd.obd] Using scan_serial to select port
[obd.obd] Available ports: ['/dev/tty.OBDII']
[obd.obd] Attempting to use port: /dev/tty.OBDII
[obd.elm327] Initializing ELM327: PORT=/dev/tty.OBDII BAUD=38400 PROTOCOL=auto
[obd.elm327] write: b'ATZ\r'
[obd.elm327] wait: 1 seconds
[obd.elm327] Failed to read port
[obd.elm327] read: b'\x00\x00\x00\x00'
[obd.elm327] write: b'ATE0\r'
[obd.elm327] Failed to read port
[obd.elm327] read: b'\x00\x00\x00\x00\x00'
[obd.elm327] closing port
[obd.elm327] write: b'ATZ\r'
[obd.elm327] ATE0 did not return 'OK'
[obd.obd] Closing connection
[obd.obd] Cannot load commands: No connection to car
[obd.obd] ===================================================================

When not specifying baud rate:

[obd.obd] ======================= python-OBD (v0.7.1) =======================
[obd.obd] Using scan_serial to select port
[obd.obd] Available ports: ['/dev/tty.OBDII']
[obd.obd] Attempting to use port: /dev/tty.OBDII
[obd.elm327] Initializing ELM327: PORT=/dev/tty.OBDII BAUD=auto PROTOCOL=auto
[obd.elm327] Response from baud 38400: b'\x00\x00\x00'
[obd.elm327] Response from baud 9600: b'\x00\x00\x00'
[obd.elm327] Response from baud 230400: b'\x00\x00\x00'
[obd.elm327] Response from baud 115200: b'\x00\x00\x00'
[obd.elm327] Response from baud 57600: b'\x00\x00\x00'
[obd.elm327] Response from baud 19200: b'\x00\x00\x00'
[obd.elm327] Failed to choose baud
[obd.elm327] closing port
[obd.elm327] write: b'ATZ\r'
[obd.elm327] Failed to set baudrate
[obd.obd] Closing connection
[obd.obd] Cannot load commands: No connection to car
[obd.obd] ===================================================================

I have tried setting a delay but however this has not resolved the issue.
I am able to successfully connect to the obd2 device via terminal using the screen function and I am able to send and receive commands.
I have also tried using just the pySerial library to communicate with the chip and was successful. Using this script

# Create a serial connection
ser = serial.Serial(port, baudrate, timeout=timeout)

# Check if the serial port is open
if not ser.is_open:
    ser.open()

# Define a list of commands
commands = [
    'ATZ\r',  
    "010d\r",
  
]

# Send commands and receive responses
for command in commands:
    ser.write(command.encode())
    time.sleep(1)
    response = ser.readline()
    
    print(response)
    
# Close the serial connection
ser.close()

Output:

b'ATZ\r\r\rOBDII  v1.5\r\r>'
b'010d\r41 0D 00 \r\r>'

It seems like this is a problem with the library not being able to send or receive data from the chip via MacOS.

Does anyone have any idea on why this is the case and any possible fixes?

Note: This might also be a problem with OBDII v1.5 as I have not tested it with OBDII v2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant