Git Product home page Git Product logo

elm327-emulator's Introduction

elm327-emulator's People

Contributors

ircama avatar noloader avatar qqj1228 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elm327-emulator's Issues

AT DP response when using ELM327-emulator

Hi Everyone,

This emulator is great. I hope I am not splitting too many hairs here...

According to ELM Electronics's ELM327 Data Sheet (p. 18), the AT DP response displays AUTO when the ELM327 performed an automatic protocol search (i.e., connect with AT SP 0). In fact, I observe the behavior when using my knockoff ELM327 OBD-II scanner from Amazon:

Command:
AT SP 0

Hex dump:
41 54 20 53 50 20 30 0d 4f 4b 0d 0d 3e 

ASCII dump:
AT SP 0
OK

>

Command:
AT DP

Hex dump:
41 54 20 44 50 0d 41 55 54 4f 0d 0d 3e 

ASCII dump:
AT DP
AUTO

>

This is what I observe when I run ELM327-emulator. Notice the ? response instead of AUTO response:

Command:
AT SP 0

Hex dump:
4f 4b 0d 0d 3e 

ASCII dump:
OK

>

Command:
AT DP

Hex dump:
3f 20 0d 0d 3e 

ASCII dump:
? 

>

Problem retrieving codes from python-obd

Hello! Thank you for your awesome emulator!
The problem I am encountering is related to the usage of python-obd library in association with the emulator, and the problem is that, some codes that are being normally returned when entering manual commands in the emulator, like EGR_ERROR, b"012d, are not being brought using the obd.commands function, as obd.commands.EGR_ERROR. Has anyone encountered this issue or do you have any idea to help me fix it. Looked into the source code of both the emulator and python-obd and didn't find a way to see the problem. Thank you!

Data points for ScanTool.net OBDLink SX

Hi Everyone/lrcama,

I wanted to add a few data points for ScanTool.net's OBDLink SX. It is different than the ELM327's. OBDLink uses an STM11xx and STM21xx, and not ELM327 chips. You can find them on Amazon at https://www.amazon.com/gp/product/B005ZWM0R4. The Amazon device uses a STM11xx.

The OBDLink is supposed to be ELM327 compatible, but it has some differences. We need to connect at 112500 8N1, and not 38400 8N1. Using 38400 8N1 will cause a hang with this device.

The version string for the STM11xx is ELM327 v1.4b. I don't know what the version string is for the STM21xx. Here's what an ATZ command and response looks like. Notice the leading 00 00 00 00.

Command:
ATZ (reset)

Hex dump:
00 00 00 00 0d 0d 45 4c 4d 33 32 37 20 76 31 2e
34 62 0d 0d 3e

ASCII dump:


ELM327 v1.4b

>

So far the rest of the commands and responses look like the ELM327.

Feel free to close the report. I wanted to offer the data points since the OBDLink is supposed to be ELM327 compatible.

Connect escaner using Bluetooth

Hi, thanks for all the efort in this emulator. I want to know how is posible to connect my phone to the emulator using bluetooth, i follow the steps in the readme file and create a port for bluetooth connection. I run the emulator using that port and succesfully test some commands using the CLI, but I can´t find any bluetooth device available to connect from my phone to test the application.
¿Is there anything else to set up before running?
I run the command below
py -m elm -p COM8 -a 38400 -s car

running elm327 as a CAN interface

Hi Ircama, i love your project! Is it possible to run your sim with a can interface. We have a linux hw with CAN/K-Line and would love to support elm327 commands. Stephan

How to emulate Bluetooth on MacOS?

Hi team, thank you for your wonderful library.

About Bluetooth connection methods, I only saw Bluetooth with Window and Linux/Unix. What about MacOS? Specifically, I'm developing iOS app that need an emulator to test connect with Bluetooth. Can this library do that? Hope to see your response soon.

Thank you and Best Regard.

Error at work

Hello, I wanted to ask if there is any way to solve the problem. When the elm emulator is running with the pyclip(pyren) program on windows, the commands sent are thrown off after connection.
Example: After launching in the terminal and using the test 2180
test 2180
Raw command:_________
'61 80 82 00 39 23 64 10 44 58 32 28 11 21 71 00 00 51 03 09 04 03 00 7D 28 00 A3 '

Command output:______
'61 80 82 00 39 23 64 10 44 58 32 28 11 21 71 00 00 51 03 09 04 03 00 7D 28 00 A3\r>'
After connecting the program to the emulator, executing
test 2180
Raw command:_________
2023-07-07 21:22:51,109 - root - ERROR - Invalid multiframe '2180'
Error in request. No data returned.
the command 2180 has the form
'2180': {
'Request': '^2180',
'Descr': '2180',
'Response': '61 80 82 00 39 23 64 10 44 58 32 28 11 21 71 00 00 51 03 09 04 03 00 7D 28 00 A3 '
},

COM3 Problem

When I try to run the program:

2024-07-14 18:12:06,015 - root - CRITICAL - Error while opening serial COM 'COM3':
could not open port 'COM3': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)

Help?

How to simulate obd2 data?

This might be a really dumb question. But how do you run a command to simulate random values coming in via obd2?

How to emulate multi frame response ?

Hi, how can i add MODE 01 PID 78 (EGT sensors) to emulator that gives back multi frame response?

Example from my car:

0178
7E8100B41780D061F01
7E8219003DA02A60000

briefly start and crash after "supposedly" changing the baud rate in GUI

Xubuntu 21.04

I might have changed the baud rate on the GUI at one point and now when I launch by typing

scantool

I get

Tue Nov 30 04:51:13 2021
Version: 2.1 for POSIX

Initializing All Modules...
---------------------------
Initializing Allegro... OK

Installing Timers... OK
Installing Keyboard... OK
Installing Mouse... OK
Loading Preferences... OK
Trying Windowed Graphics Mode... OK
Loading Data File... OK
Initializing Serial Module... OK
Opening COM4... OK

Displaying Main Menu...
-----------------------
write tty: Erreur d'entrée/sortie
*** buffer overflow detected ***: terminated
Shutting down Allegro due to signal #6
Abandon (core dumped)
arno@arno-ThinkPad-X220:~$ 

I can see the GUI window appear for an instant then disappear, so I can't reverse the setting.

I tried to look for a config file were the values for baud rate and COM port would be written/stored, to no avail.

I'd appreciate if you could point towards something.

Thanks

CRITICAL:root:Error while opening 'COM3

Got it running on com0com on Windows 10, but after restarting, it now says:

CRITICAL:root:Error while opening 'COM3':
could not open port 'COM3': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)

Cannot start ELM327-emulator.

Any idea? Thanks.

I tried to use other ports like COM4/COM5 still the same

any workarounds for getting it run with virtual COM Ports in Windows?

com0com and probably any other driver is not able to work without proper driver signature and that is true for nearly every windows in 2022 (Win10+ and 64Bit).

I don't think that disabling driver signature enforcement is a good idea, if even possible.

there seem to be commercial alternatives with at least some days of trial mode like https://www.virtual-serial-port.org

At least I guess it should be mentioned that it won't work.

see also #3

emulator starts at /dev/ttys000 on Mac OS Mojave

I'm using emulators as described and it starts at /dev/ttys000. I'm using connector for serial ports interaction and it can't find the device. Can I make somehow to start emulator at /dev/tty.XXX?

ATZ response when using knockoff ELM327

Hi Everyone,

This emulator is great. I hope I am not splitting too many hairs here...

According to ELM Electronics's ELM327 Data Sheet (p. 8), the identification string is supposed to be like the following.

ELM327 v2.3

Valid versions are 1.0, 1.0a, 1.1, 1.2, 1.2a, 1.3, 1.3a, 1.4, 1.4b, 2.0, 2.1, 2.2, and 2.3. Also see ELM Electronics AT Commands by Version.

This is what I get when I run ELM327-emulator and the ATZ command (with echo ON):

Command:
ATZ

Hex dump:
41 54 5a 0d 0d 0d 45 4c 4d 33 32 37 20 76 31 2e 
35 0d 0d 3e 

ASCII dump:
ATZ


ELM327 v1.5

>

If you are seeing ELM327 v1.5, the ELM327 v1.5 identification string is a dead giveaway that the controller is a knockoff since ELM Electronics did not produce a 1.5 revision.

Now here's the rub... The knockoff ELM327's ( ELM327 v1.5) add a spurious 0d fc in response to an ATZ. Here's what it looks like when I query a knockoff ELM327 OBD-II scanner from Amazon. Notice the extra od fc (with echo ON):

Command:
ATZ

Hex dump:
41 54 5a 0d fc 0d 0d 45 4c 4d 33 32 37 20 76 31 
2e 35 0d 0d 3e 

ASCII dump:
ATZ
�

ELM327 v1.5

>

I think the choices are:

  1. Keep using v1.5, and add the spurious od fc
  2. Use v1.4b and don't add the spurious od fc
  3. Add an option like -quirks or -knockoff that controls when od fc is added.

UDS support

First off, thanks for this great project. I'm working on various scan tools myself and did work on some ad-hoc emulators. It might make sense to join forces on one common project. Right now I'm after UDS support, i.e. answers to service IDs >= 0x10.

I realize that would lean the project more towards ECU simulation, for which some other interesting alternatives exist, but figure I'd just ask what you are thinking about that.

Proper response for unknown command

The unknown command case is handled wrongly – a real ELM327 (and the behemoth of clones) answers with ?\r\r, not just \r – the question mark is very important.

Reasoning: Said answer is very important, since it is good practice to start the ELM327 probing sequence by sending an invalid command, such as .\r, to ensure a consistent state of the send buffer – hence clients need to rely on a proper answer for unknown command.

CRITICAL - Error while processing '': string index out of range

Hi Everyone,

Thanks for this emulator. It looks like it will be very useful.

I'm working on Ubuntu 20.04, x86_64, fully patched. Python 3.8.10 is installed, and dependencies are installed. I cloned ELM327-emulator, and ran it using python3 -m elm. The emulator was waiting/listening on /dev/pts/3.

I then connected my client to the emulator via /dev/pts/3. My client configured its terminal with 38400, 8N1 like a real ELM327. I issued an ATZ from my client to reset the controller. The command hung in my client.

At the emulator there was a lot of activity:

$ python3 -m elm
2021-07-09 21:25:42,876 - root - INFO - 

ELM327 OBD-II adapter emulator v3.0.1 started on pseudo-tty port "/dev/pts/3".

Welcome to the ELM327 OBD-II adapter emulator.
ELM327-emulator is running on /dev/pts/3
Type help or ? to list commands.

CMD> 2021-07-09 21:25:59,439 - root - CRITICAL - Error while processing '':
string index out of range
Traceback (most recent call last):
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 848, in run
    request_header, request_data, resp = self.handle_request(
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 1802, in handle_request
    if cmd[1] == 'T' and org_cmd.upper()[1] != 'T':  # AT or ST shall be unspaced
IndexError: string index out of range

2021-07-09 21:25:59,440 - root - CRITICAL - Error while processing '':
string index out of range
Traceback (most recent call last):
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 848, in run
    request_header, request_data, resp = self.handle_request(
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 1802, in handle_request
    if cmd[1] == 'T' and org_cmd.upper()[1] != 'T':  # AT or ST shall be unspaced
IndexError: string index out of range

2021-07-09 21:25:59,442 - root - INFO - Unknown ELM command: 'ELM327V1.5', header=7E0
2021-07-09 21:25:59,443 - root - INFO - Unknown ELM command: 'ELM327V1.5', header=7E0
2021-07-09 21:25:59,443 - root - WARNING - Invalid request: '>ATZ'
2021-07-09 21:25:59,443 - root - WARNING - Invalid request: '>ATZ'
2021-07-09 21:25:59,444 - root - WARNING - Invalid request: '>ATZ'
2021-07-09 21:25:59,444 - root - INFO - Unknown ELM command: 'ELM327V1.5', header=7E0
2021-07-09 21:25:59,444 - root - INFO - Unknown ELM command: 'ELM327V1.5', header=7E0
2021-07-09 21:25:59,445 - root - WARNING - Invalid request: '>'
2021-07-09 21:25:59,445 - root - WARNING - Invalid request: '>'
2021-07-09 21:25:59,445 - root - WARNING - Invalid request: '>'
2021-07-09 21:25:59,445 - root - WARNING - Invalid request: '>'
2021-07-09 21:25:59,445 - root - WARNING - Invalid request: '>'
2021-07-09 21:25:59,446 - root - INFO - Unknown ELM command: 'ELM327V1.5', header=7E0
2021-07-09 21:25:59,446 - root - CRITICAL - Error while processing '?':
string index out of range
Traceback (most recent call last):
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 848, in run
    request_header, request_data, resp = self.handle_request(
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 1802, in handle_request
    if cmd[1] == 'T' and org_cmd.upper()[1] != 'T':  # AT or ST shall be unspaced
IndexError: string index out of range

2021-07-09 21:25:59,446 - root - CRITICAL - Error while processing '?':
string index out of range
Traceback (most recent call last):
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 848, in run
    request_header, request_data, resp = self.handle_request(
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 1802, in handle_request
    if cmd[1] == 'T' and org_cmd.upper()[1] != 'T':  # AT or ST shall be unspaced
IndexError: string index out of range

2021-07-09 21:25:59,446 - root - WARNING - Invalid request: '>'
2021-07-09 21:25:59,446 - root - WARNING - Invalid request: '>'
2021-07-09 21:25:59,447 - root - CRITICAL - Error while processing '?':
string index out of range
Traceback (most recent call last):
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 848, in run
    request_header, request_data, resp = self.handle_request(
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 1802, in handle_request
    if cmd[1] == 'T' and org_cmd.upper()[1] != 'T':  # AT or ST shall be unspaced
IndexError: string index out of range

2021-07-09 21:25:59,447 - root - CRITICAL - Error while processing '?':
string index out of range
Traceback (most recent call last):
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 848, in run
    request_header, request_data, resp = self.handle_request(
  File "/home/jwalton/ELM327-emulator/elm/elm.py", line 1802, in handle_request
    if cmd[1] == 'T' and org_cmd.upper()[1] != 'T':  # AT or ST shall be unspaced
IndexError: string index out of range

2021-07-09 21:25:59,447 - root - WARNING - Invalid request: '>'
2021-07-09 21:25:59,447 - root - WARNING - Invalid request: '>ATZ'
2021-07-09 21:25:59,447 - root - WARNING - Invalid request: '>ATZ'
2021-07-09 21:25:59,447 - root - WARNING - Invalid request: '>ATZ'
2021-07-09 21:25:59,447 - root - WARNING - Invalid request: '>ATZ'
2021-07-09 21:25:59,447 - root - WARNING - Invalid request: '>ATZ'
2021-07-09 21:25:59,448 - root - WARNING - Invalid request: '>ATZ'
2021-07-09 21:25:59,448 - root - INFO - Unknown ELM command: 'ELM327V1.5', header=7E0
<skip many similar blocks of messages>

2021-07-09 21:26:01,542 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,542 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,542 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,543 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,544 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,544 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,587 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,588 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,638 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,688 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,688 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,738 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,739 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,788 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,839 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,889 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,939 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,940 - root - WARNING - Invalid request: '>'
2021-07-09 21:26:01,990 - root - WARNING - Invalid request: '>'
<skip many similar messages>

I got the same result when running python3 -m elm -s car. I got the same result with Master (shown above) and v3.0.0. I also got a similar result with v2.1.0 (but output is different). Running as sudo does not seem to make a difference.

I can provide my C test program, if interested. There's not much to it though. It just issues AT commands and reads responses. After some AT commands it uses ODB commands, like 01 00 and 09 02. When testing with a knock-off ELM327 the command completes successfully. (I'm trying the ELM327-Emulator because it is faster and more convenient than doing stuff on the car in the garage).

I did not see a similar bug report, so I opened this one.

My apologies if I a doing something wrong here.

Does it contain bluetooth communication?

Hi, I realized it emulates a ELM327 adapter but using a USB communication. So, does it contain a version that is able to communicate to the application using bluettooth, because many adapters talk through bluetooth.
thanks in advance!

Supporting multiple pids for service 01

The SAE J1979 specification allows service 01 commands to include up to 6 PIDs, which can be a helpful way to improve throughput when querying many PIDs for vehicle telematics. It looks like the ELM327-emulator doesn't handle this ability yet though so I wanted to track this as a feature request.

An example command/response prompt:

> 0101030406070C3
7E8101241010007E500
7E82103010004000680
7E822077D0C00000000

Other requirements from the service 01 documents (section 7.1.1):

The purpose of this service is to allow access to current emission-related data values, including analogue inputs and outputs, digital inputs and outputs, and system status information. The request for information includes a parameter identification (PID) value that indicates to the on-board system the specific information requested.

The ECU(s) shall respond to this message by transmitting the requested data value last determined by the system. All data values returned for sensor readings shall be actual readings, not default or substitute values used by the system because of a fault with that sensor.

Not all PIDs are applicable or supported by all systems. PID $00 is a bit-encoded value that indicates for each ECU which PIDs are supported. PID $00 indicates support for PIDs from $01 to $20. PID $20 indicates support for PIDs $21 through $40, etc. This is the same concept for PIDs/OBD Monitor IDs/TIDs/InfoTypes support in Services $01, $02, $06, $08, $09. PID $00 is required for those ECUs that respond to a corresponding Service $01 request message.

IMPORTANT — All emissions-related OBD ECUs which at least support one of the services defined in this document shall support Service $01 and PID $00. Service $01 with PID $00 is defined as the universal “initialization/keep alive/ping” message for all emissions-related OBD ECUs

The request message may contain up to six (6) PIDs. An external test equipment is not allowed to request a combination of PIDs supported and PIDs, which report data values. The ECU shall support requests for up to six (6) PIDs. The request message may contain the same PID multiple times. The ECU shall treat each PID as a separate parameter and respond with data for each PID (data returned may be different for the same PID) as often as requested.

The order of the PIDs in the response message is not required to match the order in the request message.

How to play back fake speeds/etc?

I've read through the documentation and various issues/questions, and am still at a mental block on how to proceed. I'm only posting this as I've hit a brick wall.

I am hoping to use this to simulate a car ECU, to an attached handheld ODB2 reader, via a USB ELM327 adapter. All I want to play to the ODB2 reader is vehicle speed and engine RPM - no other parameters matter. I want to get to the point where I can input a speed of 10km/hr on my computer, and see 10km/hr displayed on the handheld ODB reader.

The adapter is is available at /dev/tty.usbserial-A78KFBC2, so I am initializing the program with this:
elm -p /dev/tty.usbserial-A78KFBC2 -a 38400 -s car -B 38400 -S /dev/tty.usbserial-A78KFBC2

This seems to respond appropriately with:

2024-02-17 09:12:03,174 - root - INFO - 

ELM327 OBD-II adapter emulator v3.0.0 started on serial communication port "/dev/tty.usbserial-A78KFBC2".

Emulator scenario switched to 'car'
Welcome to the ELM327 OBD-II adapter emulator.
ELM327-emulator is running on serial communication port "/dev/tty.usbserial-A78KFBC2".
Type help or ? to list commands.

At this point, no USB activity lights appear on the EML327 adapter, and the OBD2 device says "communication failure" when trying to connect via ODB2.

Despite trying various commands from the documentation, the only thing I have noticed which results in activity lights on my ELM327 adapter using elm is when I accidentally ran the following - which illuminated the USB activity light, but ultimately didn't establish a connection:

CMD> test car
______Raw command:_______________
2024-02-16 23:28:58,027 - root - INFO - Write forward data: b'CAR\r'
2024-02-16 23:28:58,231 - root - INFO - Read forward data: b'CAR\r?\r\r>'
2024-02-16 23:28:58,231 - root - WARNING - Missing data in dictionary: 'CAR'. Answer:
"b'CAR\\r?\\r\\r>'"
2024-02-16 23:28:58,231 - root - INFO - Unknown ELM command: 'CAR', header=7E0
'<writeln>?</writeln>'

______Command output:____________
'?\r\r>'

At this point I can't tell if I'm barking up the wrong tree and trying to get ELM327-emulator to do something it's not supposed to do, or if I'm missing something obvious. Either way, any advice at all for getting me closer to what I'm trying to do would be greatly appreciated!

"NO DATA" for PIDs that are clearly in the obd_message.py file

as stated, I am trying to get MODE 21 for specifically a Prius C and I see the PIDs listed, but I don't understand how to get them.

CUSTOM_V01': {
            'Request': '^2181' + ELM_FOOTER,
            'Descr': 'Battery Block Voltage -V01',
            'Equation': '(A * 256 + B) * 79.99 / 65535',
            'Min': '12',
            'Max': '20',
            'Unit': 'V',
            'Header': ECU_ADDR_H,
            'Response': [
                        HD(ECU_R_ADDR_H) + SZ('10') + DT('22 61 81 37 7C 37 1A') +
                        HD(ECU_R_ADDR_H) + SZ('21') + DT('38 08 38 08 38 BC 38') +
                        HD(ECU_R_ADDR_H) + SZ('22') + DT('BC 37 95 37 95 37 33') +
                        HD(ECU_R_ADDR_H) + SZ('23') + DT('37 22 38 49 38 5A 37') +
                        HD(ECU_R_ADDR_H) + SZ('24') + DT('53 37 95 AF 3B 09 74'),
                        HD(ECU_R_ADDR_H) + SZ('10') + DT('22 61 81 38 72 38 20') +

I setup a port pair between COM3 and COM4 using comOcom. the I connected your emulator to COM3 and connected YAT to COM4. I then typed for example 'ATVR' and I get a correctly faked voltage reading. However if I type 2181 I get "No Data"

2101
2101<CR>7E8 10 1B 61 01 6F 00 44 02 <CR>7E8 21 C6 28 38 61 4B 17 21 <CR>7E8 22 31 00 2B 01 30 83 31 <CR>7E8 23 04 00 31 00 5B 39 5F <CR><CR>><LF>

2161
2161<CR>NO DATA<CR><CR>><LF>

2130
2130<CR>NO DATA<CR><CR>><LF>

2129
2129<CR>NO DATA<CR><CR>><LF>

2161
2161<CR>NO DATA<CR><CR>><LF>

2181
2181<CR>NO DATA<CR><CR>><LF>

ATRV
ATRV<CR>13.1V<CR><CR>><LF>
Name ShortName ModeAndPID Equation Min Value Max Value Units Header
FR Wheel Speed FR WS 2103 A * 32 / 25 0 200 km/h 7B0
FL Wheel Speed FL WS 2103 B * 32 / 25 0 200 km/h 7B0
RR Wheel Speed RR WS 2103 C * 32 / 25 0 200 km/h 7B0
RL Wheel Speed RL WS 2103 D * 32 / 25 0 200 km/h 7B0
Fuel System Status #1 (OL=1,CL=2,OLDrive=4,OLFault=8,CLFault=16) FSS1 2103 A 1 16   7
Short FT #1 Short FT1 2103 C * 199.2 / 255 - 100 -100 99.2 % 7
Long FT #1 Long FT1 2103 D * 199.2 / 255 - 100 -100 99.2 % 7
IGN Advance IGN 2103 E / 2 - 64 -64 63.5 deg 7

Inject additional PIDs with data from external sensors to the existing PIDs from the vehicle OBD adapter

I understand that your (great!) software can do that, but I would need something to get started.
What I want to do:
add external (physical) sensors to a Raspberry Pi (like fuel pressure and boost pressure, exhaust temperature etc) and add PIDs for these sensors that are not existing in the ECU(s) that the vehicle has.
I have lets say an engine ECU that provides RPM, coolant temp etc. and I have an OBD2-interface that reads that data.
I can loop-through the data from OBD interface and manipulate the data - I understood and tested that part.
(actually, for bench testing I started your car scenario at /dev/pts/0, and looped that through and modified the PID values, as I don't have the actual car at my desk, and put the modified interface to /dev/pts/1, and then read out that interface with my OBD software. Later I would replace the /dev/pts/0 with the actual OBD interface).
Works so far - but I don't get what I need to do to modify PID values (or add PIDs) with data from lets say text files containing actual measurement data from external sensors that I added. I only understand how do do command-line based modifications to the live values.
It would be great to get a short example to start with... :-)
I think I need to find out how to do insert data from a file to a command like
emulator.answer['SPEED']='NO DATA'

--> something like auto starting the emulation with multiple commands like
emulator.answer['SPEED']=content_of_file1
emulator.answer['RPM']=content_of_file1
emulator.answer['customPID']=content_of_file3
etc..
What would be the best approach?

trouble with emulator.answer

I have this up and running on a linux machine and I am getting valid values on the arduino it's connected to. It's a barebones sketch printing out RPM and coolant temp. I get non-zero values for coolant in default scenario and both rpm and coolant temp in the car scenario. When I copy paste your example RPM line emulator.answer['RPM'] = '\0 ECU_R_ADDR_E + " 04 41 0C %.4X" % int(4 * 500) \0\r' I get the following reply Error executing command: name "emulator" is not defined with no change to the values I see on the arduino terminal. I tried various other emulator.answer examples all with the same result. Other emulator commands I discovered with tab complete work like emulator.get_pty, just not emulator.answer. Tried installs from git and pip with no difference.
I'm a car guy with very little programming knowledge, I expect I'm doing something obviously wrong but I can't figure it out.

Wrong RPM being set at certain intervals

I was using this emulator test my OBD2 application and noticed that at certain intervals, the RPM command that is returned is sometimes incorrect, not sure if this expected behaviour or not. It seems to be at certain interval, below is are the RPMs I observed where the data being sent back from the emulator is incorrect.

2320 - expected hex (24 40) - received (2 40)
2340 - expected hex (24 90) - received (2 90)
2360 - expected hex (24 E0) - received (2 E0)
3340 - expected hex (34 30) - received (3 30)
3360 - expected hex (34 80) - received (3 80)
3380 - expected hex (34 D0) - received (3 D0)
4360 - expected hex (44 20) - received (4 20)
4380 - expected hex (44 70) - received (4 70)
4400 - expected hex (44 C0) - received (4 C0)

legacy protocol support?

I tried running the emulator & setting it to protocol # '3' (ISO-9141-2), but it simply ignored the 'AT SP3' command and kept using CAN. So, it apparently can only speak CAN.

Is there a way to configure it for other 'legacy' protocols? Do all of the communications & messaging need to be created from scratch to support such protocols?

Connect Physical device

Thanks for this awesome library!

I do understand that it's rather meant to test your own software, however I'm trying to feed a device in my car with the OBD Data from this script. The device has a regular OBD plug and reads data from my car while driving and takes actions based on the status of the car. I'm searching for 2 days now for a possibility to connect the OBD plug somehow with my Raspberry Pi / any Linux computer and use this script to emulate my car. Do you have any idea/experience how this could be archived? I would need to somehow connect the OBD plug with my Linux device and feed it with the data of your emulator.

Limited responses via 0x7DF(Functional request)

First interesting thing is why is default can request id is 0x7E0 instead of 0x7DF or 0x18DB33F0. Because 0x7DF is functional address so I would expect many response from most of ecu. But when I send 09 0a (OBD ecu name request), the result is very insufficient.

Unknown request: '0160', header=7E0

I want to use this ELM327 emulator in connection with Perl OBD-II Logger.
Unfortunately right from the beginning I encounter the following error: " Unknown request: '0160', header=7E0"

CMD> 2022-01-02 09:29:01,777 - root - DEBUG - Received 'ATZ'
2022-01-02 09:29:01,777 - root - DEBUG - Handling: 'ATZ', header '7E0', ECU '7E0'
2022-01-02 09:29:01,777 - root - DEBUG - Instantiating ECU task "Default ECU Task module" for ECU "7E0"
2022-01-02 09:29:01,780 - root - DEBUG - Description: AT RESET, PID AT_RESET (ATZ)
2022-01-02 09:29:01,780 - root - DEBUG - Resetting counters and sleeping for 0.5 seconds
2022-01-02 09:29:02,300 - root - DEBUG - Reset and sleep 0.5 seconds
2022-01-02 09:29:02,300 - root - DEBUG - Processing: '<writeln></writeln><writeln></writeln><writeln>ELM327 v1.5</writeln>'
2022-01-02 09:29:02,300 - root - DEBUG - Write: '\r\rELM327 v1.5\r\r>'
2022-01-02 09:29:02,558 - root - DEBUG - Received 'ATE0'
2022-01-02 09:29:02,559 - root - DEBUG - Handling: 'ATE0', header '7E0', ECU '7E0'
2022-01-02 09:29:02,559 - root - DEBUG - Description: AT ECHO, PID AT_ECHO (ATE0)
2022-01-02 09:29:02,559 - root - DEBUG - set ECHO ON/OFF : False
2022-01-02 09:29:02,559 - root - DEBUG - Processing: '<writeln>OK</writeln>'
2022-01-02 09:29:02,559 - root - DEBUG - Write: 'OK\r\r>'
2022-01-02 09:29:02,820 - root - DEBUG - Received 'ATL0'
2022-01-02 09:29:02,823 - root - DEBUG - Handling: 'ATL0', header '7E0', ECU '7E0'
2022-01-02 09:29:02,823 - root - DEBUG - Description: AT LINEFEEDS, PID AT_LINEFEEDS (ATL0)
2022-01-02 09:29:02,823 - root - DEBUG - set LINEFEEDS ON/OFF : False
2022-01-02 09:29:02,824 - root - DEBUG - Processing: '<writeln>OK</writeln>'
2022-01-02 09:29:02,824 - root - DEBUG - Write: 'OK\r\r>'
2022-01-02 09:29:03,078 - root - DEBUG - Received 'ATS0'
2022-01-02 09:29:03,078 - root - DEBUG - Handling: 'ATS0', header '7E0', ECU '7E0'
2022-01-02 09:29:03,079 - root - DEBUG - Description: AT Spaces off or on, PID AT_SPACES (ATS0)
2022-01-02 09:29:03,079 - root - DEBUG - set SPACES False
2022-01-02 09:29:03,079 - root - DEBUG - Processing: '<writeln>OK</writeln>'
2022-01-02 09:29:03,079 - root - DEBUG - Write: 'OK\r\r>'
2022-01-02 09:29:03,336 - root - DEBUG - Received 'ATI'
2022-01-02 09:29:03,336 - root - DEBUG - Handling: 'ATI', header '7E0', ECU '7E0'
2022-01-02 09:29:03,337 - root - DEBUG - Description: AT ELM327 version string, PID AT_I (ATI)
2022-01-02 09:29:03,337 - root - DEBUG - Processing: '<writeln>ELM327 v1.5</writeln>'
2022-01-02 09:29:03,337 - root - DEBUG - Write: 'ELM327 v1.5\r\r>'
2022-01-02 09:29:03,337 - root - DEBUG - Received '0100'
2022-01-02 09:29:03,337 - root - DEBUG - Handling: '0100', header '7E0', ECU '7E0'
2022-01-02 09:29:03,337 - root - DEBUG - Description: PIDS_A, PID ELM_PIDS_A (0100)
2022-01-02 09:29:03,338 - root - DEBUG - Processing: '<string>SEARCHING...</string><exec>time.sleep(3)</exec><writeln></writeln><header>7EA</header><size>06</size><data>41 00 98 3A 80 13</data><pos_answer>BE 3F A8 13</pos_answer>'
2022-01-02 09:29:03,338 - root - DEBUG - Write: 'SEARCHING...'
2022-01-02 09:29:06,352 - root - DEBUG - Evaluated command: time.sleep(3) -> None
2022-01-02 09:29:06,352 - root - DEBUG - Write: '\r4100983A8013\r4100BE3FA813\r\r>'
2022-01-02 09:29:09,190 - root - DEBUG - Received '0100'
2022-01-02 09:29:09,190 - root - DEBUG - Handling: '0100', header '7E0', ECU '7E0'
2022-01-02 09:29:09,190 - root - DEBUG - UDS P3 timer expired: running stop() method for ECU task "Default ECU Task module", ECU="7E0".
2022-01-02 09:29:09,190 - root - DEBUG - Description: PIDS_A, PID ELM_PIDS_A (0100)
2022-01-02 09:29:09,191 - root - DEBUG - Processing: '<header>7EA</header><size>06</size><data>41 00 98 3A 80 13</data><pos_answer>BE 3F A8 13</pos_answer>'
2022-01-02 09:29:09,191 - root - DEBUG - Write: '4100983A8013\r4100BE3FA813\r\r>'
2022-01-02 09:29:09,191 - root - DEBUG - Received '0120'
2022-01-02 09:29:09,191 - root - DEBUG - Handling: '0120', header '7E0', ECU '7E0'
2022-01-02 09:29:09,191 - root - DEBUG - Description: PIDS_B, PID ELM_PIDS_B (0120)
2022-01-02 09:29:09,191 - root - DEBUG - Processing: '<header>7EA</header><size>06</size><data>41 20 80 01 A0 01</data><pos_answer>90 15 B0 15</pos_answer>'
2022-01-02 09:29:09,191 - root - DEBUG - Write: '41208001A001\r41209015B015\r\r>'
2022-01-02 09:29:09,192 - root - DEBUG - Received '0140'
2022-01-02 09:29:09,192 - root - DEBUG - Handling: '0140', header '7E0', ECU '7E0'
2022-01-02 09:29:09,192 - root - DEBUG - Description: PIDS_C, PID ELM_PIDS_C (0140)
2022-01-02 09:29:09,192 - root - DEBUG - Processing: '<header>7EA</header><size>06</size><data>41 40 44 CC 00 21</data><pos_answer>7A 1C 80 00</pos_answer>'
2022-01-02 09:29:09,192 - root - DEBUG - Write: '414044CC0021\r41407A1C8000\r\r>'
2022-01-02 09:29:09,192 - root - DEBUG - Received '0160'
2022-01-02 09:29:09,192 - root - DEBUG - Handling: '0160', header '7E0', ECU '7E0'
2022-01-02 09:29:09,193 - root - INFO - Unknown request: '0160', header=7E0
2022-01-02 09:29:09,193 - root - DEBUG - Processing: '<writeln>NO DATA</writeln>'
2022-01-02 09:29:09,193 - root - DEBUG - Write: 'NO DATA\r\r>

`

Sending/Receiving data from external app (?)

Not sure if it's possible, but using ELM 327 Emulator, I managed to make a Virtual COM Port (COM3 & COM4)
image

But when I go and use SerialPort in Node JS, nothing happens. I'm most likely doing something wrong, and probably not related to this, just want to know, is it possible?

image

Maybe you know something I don't. Thanks!

How To: return remove newline from echo

Looking to remove the newline \n from the echo
ATSP0 ( and all other commands) is actually returning me
ATSP0\r\nOK\r\r>

image

I can see how to change the newlines at the end but not for the echo

(Feature) Serve commands via network

Many ELM327-based OBD2 adapters work via WiFi. It would be cool to have the ELM327-emulator listen via a customizable port. That way it could serve as a testbed for OBD2 apps running on mobile clients which usually can't connect via serial port.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.