LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trim a single bit from a byte?

Solved!
Go to solution

You should read the CANlib documentation which explains CanReadSpecific. Sounds like that is not the function you want, and CanReadSpecificSkip might be a better choice. You cannot run any of those functions standalone, because the device won't be open and configured; you need to use it in the context of a larger program, such as the CAN example. I don't know why it wouldn't accept the ID you entered, though - what text, exactly, did you enter?

 

If you read the documentation, you'll see that canSetAcceptanceFilter is basically the same as two calls to canAccept (one to set the mask, the other to set the code). The example code has those two calls to canAccept already (although in the version that I just downloaded, there's a broken wire going into each of them). So, if you fix that, you can set the ID filtering there.

 

Looking further into the CAN example, canRead does not return a string. It returns several separate values, one of which is the message ID. Another output is the data as an array of bytes. There's a separate function that grabs all those values and combines them into a string for a pretty display. For analyzing a CAN packet, you should use the raw data returned by the canRead, not the formatted string.

Message 21 of 28
(2,374 Views)

WOW thank you so much!! this guide was exactly what I needed!  I dont know how in my hours of trying to google search this never came up Upon reading it does seem that I want can read specific skip! Thank you!

0 Kudos
Message 22 of 28
(2,344 Views)

Any idea why the concatinate string has a red border in this VI that was uploaded?


@jpc335 wrote:

Here is my VI.  Yes they are formatted as hexadecimal strings.  I am just trying to get part of the programming done before I get to the testing site.

 

I was told by the manufacturer that the 3 bit hexadecimal string can then be converted into usable numbers.  So if its faster/easier to replace the first byte with a 0 or turn it into a 3 bit hex string.  Either will work.

 

Thank you for responding so fast I should have posted here yesterday haha.  I haven't used LabVIEW  for about 5 years and that was just basic stuff so I'm getting back into the swing of things.


 

0 Kudos
Message 23 of 28
(2,338 Views)
The red border indicates a breakpoint set on that function: http://digital.ni.com/public.nsf/allkb/113422F9F1F73A8A8625670D00547B7C
0 Kudos
Message 24 of 28
(2,316 Views)

Ah, I was confused becuase it was set, but disabled.

0 Kudos
Message 25 of 28
(2,307 Views)

OK so hopefully this is my last hurdle.  ive edited the KvCanExample to read only the designated channels and have isolated the part of the output string to use for my previous vi.  Here is the issue, the output string outputs the hex values as a text string.  This appears as 01 01 F0 98 C0 09 FC F1.  These are the hex values I need in my program, however labview recognizes them as text.  It is really an 8 byte string of hex values but labview does not recogize as such.  I need to convert this to an 8 byte hex string wit the same characters and not the bytes for those characters.  Any ideas?

0 Kudos
Message 26 of 28
(2,282 Views)

Use Bob's code above and convert the byte array back to a string using "byte array to string".

0 Kudos
Message 27 of 28
(2,234 Views)
As I already suggested, don't use the output of the string formatter function. The canRead function gives you an array containing the data; use that. There's no reason to convert to a string and then immediately convert back to numeric data.
0 Kudos
Message 28 of 28
(2,195 Views)