I have a OBDII (D-CAN) to USB cable that I have been using in Windows without any issues.
Following XOJO tutorial, in Serial1’s DataAvailable, I added this code:
MsgBox "Getting Data … "
TextArea1.AppendText(me.ReadAll)
I connected the cable to the car and executed the code. USB Serial port was listed and I hit the connect button. Nothing seems to happen after that. Since I am not seeing message box "Getting Data … ", I am assuming nothing is coming in because DataAvailable is not firing. Serial Port settings are correct (Bits per second 9600, Data bits 8, Parity None, Stop bits 1). I am a newbie. Please let me know if I am missing anything here. Appreciate your help.
Also make sure you send the right data to it using the right data type (mostly will be binary -nil encoded string-)
And check the LastErrorCode of the serial port[/quote]
Thank you. I added this code in Connect/Disconnect button.
Dim svalue as Integer
svalue = Serial1.LastErrorCode
if svalue <> 0 then
MsgBox "Serial Port Error Code is " + Chr(svalue)
end if
MsgBox is not displayed. So I think it is ok. But DataAvailable event for Serial is not firing. I have MsgBox as the first statement for this event. It doesn’t show up.
Can you elaborate what you mean by that statement?
Do you mean you have been using it with Xojo without issues and only had issues when you moved to using DataAvailable (I would presume from polling)? Do you mean you have been using it with other Serial Terminals (e.g. Teraterm, Coolterm) but can’t seem to receive anything when moving the serial interface to Xojo?
[quote=433515:@LangueR]Can you elaborate what you mean by that statement?
Do you mean you have been using it with Xojo without issues and only had issues when you moved to using DataAvailable (I would presume from polling)? Do you mean you have been using it with other Serial Terminals (e.g. Teraterm, Coolterm) but can’t seem to receive anything when moving the serial interface to Xojo?[/quote]
Sure. I have been using OBDII (D-CAN) to USB cable with other Windows software. But when I tried to use the same cable with Xojo (MAC), DataAvailable event is not getting fired.
I followed serial port tutorial. When I run xojo application, it shows up in the list of serial ports. But I don’t see any data coming in.
I used this code to check and it is always zero.
Dim sbytes as Integer
sbytes = serial1.BytesAvailable
if sbytes > 0 then
MsgBox "Serial Port Bytes " + str(sbytes)
end if
Usually you need to send a command to the OBD (on board diagnostics) computer to get it to respond with some data.
Depending on what sftware you have been using this cable with that software may already be sending an initial command to the OBD system.
OBD can be using any one of 5 different protocols so determining which one is in use is probably the first thing to figure out.
There are lots of online resources available about programming OBD II
[quote=433589:@Norman Palardy]Usually you need to send a command to the OBD (on board diagnostics) computer to get it to respond with some data.
Depending on what sftware you have been using this cable with that software may already be sending an initial command to the OBD system.
OBD can be using any one of 5 different protocols so determining which one is in use is probably the first thing to figure out.
There are lots of online resources available about programming OBD II
Thanks! Protocol is ISO 15765-4 CAN. Protocol can be set to auto by “AT SP 0”. How do I send these commands from xojo application? Any example for sending this command and get basic data like coolant temperature (0105) ?
I sent command using Serial1.write(“AT DP”) (display protocol).
DataAvailable event fires up and TextArea1.AppendText(me.ReadAll) displays ‘AT DP’.
Am I missing any step?
Sounds like the ODP is configured to echo everything
I’d try another command and see what results you get
But the point is that the ODP doesnt just send data without being told what to do by sending it a command
You send a command & it replies
You send another & it replies
and so on
Tried ATZ also. No response
In Windows, using another software, I verified cable is working fine and receiving data.
For some reason xojo application is not receiving any data