SSM Initialization code in VB, How?

User topics relating to software that logs data from ECUs

Moderator: Freon

Postby cboles » Thu Jan 05, 2006 10:22 pm

You are mixing concepts. The ECU does not speak any form of human readable text, or ASCII. An ASCII space (" ") to it is 32. The ECU does not want to see the 4 bytes which encode the ASCII string "0x1C" - it wants to see 1 byte which is the value 0x1C hex, 28 decimal, or 00011100 binary. I am not very familiar with VB, but there must be a way to send a byte or array of bytes out the serial port. This is what you need to do. You can't send strings. Also, VB uses unicode for strings which have 2 bytes per character, to make things more confusing.
cboles
Site Admin
 
Posts: 1233
Joined: Wed Dec 29, 2004 5:45 pm
Location: Seattle, WA

Postby Navybluesubaru » Fri Jan 06, 2006 6:03 am

The thing that people are not realizing that I am going to have to overcome is that VB wants to output LITERAL STRINGS. When I tell it to output "0x1C" that is what it puts out. It does not know that I am referring to a HEX value, it just sees it as simple text. In a manner of speaking, VB is stupid in that respect. There is no way when outputting data via the mscomm control to specify what format the data you are passing is in, whether it be decimal, hex, or ascii.

There is a way to generally specify that something is hex, and that is like the following:

&H80
&H10
&HF0

By using "&H" before each part, it recognizes that as a genuine hex value.

I am going to have to something like this:
Comm.Output = &H80 & &H10 & &HF0 ........so forth so on

Instead of this:
Comm.Output = "0x80 0x10 0xF0 "..........so forth so on
In the example directly above, vb sees that as a literal string just as you see it, no specific type of value or special meaning.

The first example is how I am going to have to do it, and Im sure i'll figure it out soon enough.

The problem this whole time is really based on vb's inability to easily send data in special formats instead of plain strings.

Jeff
Navybluesubaru
 
Posts: 52
Joined: Wed Dec 28, 2005 4:19 pm
Location: Jacksonville

Postby cdvma » Fri Jan 06, 2006 9:37 am

VB6 doesn't want to send strings, it wants to send binary. If you feed it a string it will convert it first into bytes. Its just convenient to not have to do it youself so it allows you to put stuff in double-quotes. You can convert an array of bytes to a string first, send each byte by itself, build a string originally with the bytes or whatever then just pass your string or the individual bytes to the serial port. You don't even have to deal with hex if you don't want to, you can use decimal.

If it absolutely only takes strings just convert it to a string before sending it. It won't print but it will make sence to the computer/ECU.
cdvma
 
Posts: 86
Joined: Tue Jan 04, 2005 9:18 pm
Location: Roch. Inst. of Tech.

Postby cboles » Fri Jan 06, 2006 9:52 am

There are many VB apps out there that talk to non-ASCII serial devices, such as home automation controllers. I'm sure you will find it easy to do once you find an example.

Colby
Last edited by cboles on Mon Jan 09, 2006 9:50 pm, edited 1 time in total.
cboles
Site Admin
 
Posts: 1233
Joined: Wed Dec 29, 2004 5:45 pm
Location: Seattle, WA

Postby Navybluesubaru » Fri Jan 06, 2006 10:40 am

What im going to end up doing is send the initialization code a couple of times in different formats and see which one gives me a correct response. Based on those results, I will adjust the program accordingly.

Jeff
Navybluesubaru
 
Posts: 52
Joined: Wed Dec 28, 2005 4:19 pm
Location: Jacksonville

Postby Zepp » Mon Jan 09, 2006 8:09 pm

Taken from a quick search....

The Output property can transmit text data or binary data. To send text data using the Output property, you must specify a Variant that contains a string. To send binary data, you must pass a Variant which contains a byte array to the Output property.

eg.
create an arrary of variants of the values you wish to send then send the array..

Likewise, when reading the port ... you can assign the input to an array of variants and process each value..

Be sure to set the InputMode of the Comm Object to comInputModeBinary so you will return an array of variants.

Hope this helps

Zepp
Last edited by Zepp on Mon Jan 09, 2006 8:28 pm, edited 1 time in total.
Zepp
 
Posts: 11
Joined: Sun Aug 07, 2005 7:32 am
Location: Australia, SA

Postby Zepp » Mon Jan 09, 2006 8:23 pm

Quick Example (from memory) dont use windoze any more:)

Code: Select all
Dim Out (0 to 8) as Variant

..
.. port open stuff
..

Out(0) = &H80
Out(1) = &H10
Out(2) = &HF0
...
...

Comm.Output  = Out



Hope this helps a little more


Zepp
Zepp
 
Posts: 11
Joined: Sun Aug 07, 2005 7:32 am
Location: Australia, SA

Postby Navybluesubaru » Mon Jan 09, 2006 8:31 pm

Yea thats the direction I am headed. I was going to compile a string and pass it for output but that wont work. I'll have to send actual hex values out instead of strings. It will be more difficult but im sure i'll manage.

Jeff
Navybluesubaru
 
Posts: 52
Joined: Wed Dec 28, 2005 4:19 pm
Location: Jacksonville

Postby Zepp » Mon Jan 09, 2006 8:37 pm

I think you will find that when it comes to processing the responses you'll will find the going easier as the data is sitting in nice usable arrays already. The Last thing I'd want to be messing around with is string processing ... <YUK>

Zepp
Zepp
 
Posts: 11
Joined: Sun Aug 07, 2005 7:32 am
Location: Australia, SA

Postby cboles » Mon Jan 09, 2006 9:37 pm

Yes, talking with the ECU has nothing to do with ASCII strings, so avoid them at all costs. Look how much confusion was generated already! :D
cboles
Site Admin
 
Posts: 1233
Joined: Wed Dec 29, 2004 5:45 pm
Location: Seattle, WA

Previous

Return to Data Logging Software

Who is online

Users browsing this forum: No registered users and 7 guests

cron