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

Does this library work with ELM327-emulator? #32

Open
jrcichra opened this issue Mar 22, 2020 · 4 comments
Open

Does this library work with ELM327-emulator? #32

jrcichra opened this issue Mar 22, 2020 · 4 comments

Comments

@jrcichra
Copy link

Description

I'm trying to test this library against https://github.com/Ircama/ELM327-emulator. I got this error after doing the following:

justin@justin-3900x:~/git/ELM327-emulator$ python3 -m elm
2020-03-22 10:22:00,993 - root - INFO - 

ELM327 OBD-II adapter emulator started

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

CMD> run 
Error executing command: name 'run' is not defined
CMD> help

Available commands include the following list (type help <topic>
for more information on each command). Besides, any Python
command is accepted. Autocompletion is fully allowed.
================================================================
color     default  engineoff  history  pause   quit   resume    wait
counters  delay    help       merge    prompt  reset  scenario

CMD> scenario 
AT         car        default    engineoff  
CMD> scenario car
Emulator scenario switched to 'car'
ATZ> ATZ

------
func main() {
	serialPath := flag.String(
		"serial",
		"/dev/pts/3", // "/dev/ttyUSB0",
		"Path to the serial device to use",
	)

	flag.Parse()

	dev, err := elmobd.NewDevice(*serialPath, true)

	if err != nil {
		fmt.Println("Failed to create new device", err)
		return
	}



justin@justin-3900x:~/git/smartcar/containers/obdii$ ./obdii 
Failed to create new device Write echo mismatch: "ATZ" not suffix of ""
justin@justin-3900x:~/git/smartcar/containers/obdii$ 

# Environment
- [ ] **Operating system:** Ubuntu 19.10
- [ ] **Go version**: 1.13
- [ ] **Git commit**: 334e700512ddaaf69fcd31a95542b31a01de8218
- [ ] **ELM327 device version**: https://github.com/Ircama/ELM327-emulator 
@jrcichra
Copy link
Author

Here's what I'm seeing stepping through with VSCode debugging:

image

@jrcichra
Copy link
Author

I'm betting it's because the mentioned library does not start with echoing...

@rzetterberg
Copy link
Owner

Hey @jrcichra!

I have never used an emulator before, but I have been wanting to add an emulator in the testing suite. So thanks for bring that to my attention.

Yes, the problem you are encountering has to do with the library expecting the device to echo back all commands that you send to it.

The library does two things when it is initialized:

  • Reset the device
  • Enable automatic protocol discovery

Resetting a device will cause the device to use the default factory settings, one of which is enabling echoing. This is the default behavior of a real ELM327-device according to the data sheet.

The goal of this library was to make it easy to use, hence the resetting, automatic protocol discovery, echo verification etc. However, lately I have been thinking about changing how the library works, so that only the user of the library decides which commands are sent to the device, and not the library. This (your problem) is another reason why changing how the library works is a good idea.

What I will do is change how the library works, and then I'm sure you will be able to use the emulator. After that we can look at how we could integrate the emulator in the test suite.

@jrcichra
Copy link
Author

I'm thinking now, if the data sheet for ELM327 should have echoing on by default, it makes more sense to fix the emulator, not this codebase.

I like the ease of use this library presents. Maybe we can add checks for non-standard ELM327 behaviors and account for them.

@jrcichra jrcichra changed the title Does this library work with ELM327-emulator? I'm struggling Does this library work with ELM327-emulator? Jun 30, 2020
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

2 participants