LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial write error

Guys,

 

If you look at this diagram:

SendMethod.PNG If I use the RED box and send to serial port then my receiver would keep getting random 1 and 0 but if I use the blue box, I get exactly what I'm sending.  I prefer the RED box method because it allows me to send more customizable pattern of 1 and 0.  Could someone please tell me what have I done wrong and should I do to make it right?   Thanks

0 Kudos
Message 1 of 9
(3,596 Views)

You are confusing binary and ASCII.

 

Your upper part is taking 16 characters of A.  Then picking them off 1 at a time and converting them to the U8 equivalent of that character, which is hexA or decimal 10.  It is the new line character.

 

Your lower part is taking an I64 quad integer which is hex value AAAA AAAA AAAA AAAA and flattening that to a string.  Since each pair of A's is a byte, you have hex AA or decimal 170.  So you have 8 of the hex AA ASCII character which is the raised little "a" in the extended part of the ASCII table.

 

So the results are two completely different strings.  I'm not sure what you mean by "random ones and zeroes".  There is nothing random about them.  They are just the binary representation of whatever ASCII characters you are sending.

 

One problem you might have in your loop is that you are sending out the data over and over again with a 0 millisecond wait.  You are probably going to flood your serial port buffer by loading it with data faster than it can send it out.

 

Message Edited by Ravens Fan on 11-10-2009 01:49 PM
Message 2 of 9
(3,587 Views)

You're right so I changed it to flatten but I'm still getting the same problem.  The modem intepreted it as random 1 and 0 because that is what's being shown on my modem received side.  Here is my attachment.

 

SendMethod2.PNG

Message Edited by lavalava on 11-10-2009 01:07 PM
0 Kudos
Message 3 of 9
(3,579 Views)

Reference to post #3:

 

This is the data pattern that I'm getting on the receiver side:

000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000000000000101000001010000000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000000000000101000000000000000000000000000001010000000000000000000000000000010100000000000000000000

 

 

 

0 Kudos
Message 4 of 9
(3,572 Views)

Ok, I've made a little progress.  I added an I8 to the output and into Flatten Anything and this is what I'm getting on the receiver side:

 

010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000010100000101000001010000

 

This appears to be converting to I16 instead of I8.   Is there a way to force it to always go down to I8 at all time?


Message Edited by lavalava on 11-10-2009 01:33 PM
0 Kudos
Message 5 of 9
(3,564 Views)

How did you get your characters of 1's and 0's.  Is the other side of the modem converting the boolean bits to 1's and 0's?

 

It looks like you are basically getting a 32 bit pattern there.  I'm not sure exactly where it starts.  But 32 bits makes sense since you are going from character A and converting that to a U32 number which is the default datatype for your hex string to number conversion.  (Wire a U8 constant into that function and you will get 8 bits). 

 

You are also ending your write with another hex 0A since you have the write termination character enabled.

 

What are you really trying to do here and why?

 

Perhaps rather than messing around with the datatype conversions as you are doing, you could just create boolean arrays, convert them to U8 bytes arrays, and convert them to string characters.

 

 

Message 6 of 9
(3,554 Views)

The 'A' in your string is not equal to hexidecimal 0xA or 0xAA.  Change the view of the string constant 'A' to "Hex Display" and you will see that ASCII 'A' is 0x41.  After you change the view to hex display type in AA and you should get a 01 binary pattern.

Message 7 of 9
(3,543 Views)
Okay, I got it guys.  I had to divide by 2 because flatten anything was designed for ASCII and ASCII takes 2 HEX.  Does this sound right?
0 Kudos
Message 8 of 9
(3,533 Views)

Finally, I got it!

 

010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101

0 Kudos
Message 9 of 9
(3,531 Views)