Jump to content

SERIAL termination character issue


Recommended Posts

Hi guys!

i spent quite a lot time in searching in these forums to know exactly what i want. but i couldnt understand somehow. thats why posting it. I have connected my labview vi with my PIC microcontroller. The piC is sending it a sensors data continuously in the form of data stream like the following

u253vx132y

this stream gets updated at regular intervals so this 253 and 132 actually represents sensors data.

currently im using match pattern function of strings to separate 253 and 132 and then performs some maths operation on them.

sometimes the stream gets this form

u25vx132y

now if you compare the above two data streams , the first one is of 10 bytes and second one is of 9 bytes.

this puts me thinking ke what to keep the value of byte count .

then i think to use a termination character. but im unable to use it. i tried all the methods but it dint work. please tell me how it works. im using a serial monitor program, i put \n as a termination character, but when i send a string from it like hello\n

it doesnt seem to terminate. Please tell me how to do this

Link to comment

QUOTE (Shaiq Bashir @ Jun 19 2008, 12:32 PM)

u253vx132y

then i think to use a termination character. but im unable to use it. i tried all the methods but it dint work. please tell me how it works. im using a serial monitor program, i put \n as a termination character, but when i send a string from it like hello\n

it doesnt seem to terminate. Please tell me how to do this

You could use the last value in the string as a termination character - is it always y?

Link to comment

QUOTE (crelf @ Jun 19 2008, 09:48 PM)

You could use the last value in the string as a termination character - is it always y?

its not working sir. im posting my file here. please check it out.

Yes it will always be "y". but remember that the problem is this that the values in between can be of 1 digit ,2 digits or 3 digits, so byte count is creating problem for me.

please help me

Link to comment

QUOTE (Shaiq Bashir @ Jun 19 2008, 01:38 PM)

its not working sir. im posting my file here. please check it out. Yes it will always be "y". but remember that the problem is this that the values in between can be of 1 digit ,2 digits or 3 digits, so byte count is creating problem for me.

I haven't been called "sir" since I was in the military :D

You can set the byte count to something higher than what you'd expect. The read will wait until it gets the number of bytes or the terminiation character, whichever comes first.

Link to comment

QUOTE (crelf @ Jun 19 2008, 11:08 PM)

I haven't been called "sir" since I was in the military :D

You can set the byte count to something higher than what you'd expect. The read will wait until it gets the number of bytes or the terminiation character, whichever comes first.

thanks for ur help. can u provide me any example plz

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.