Receive RS232 string

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Adrien DG
Posts: 15
Joined: Thu Jun 11, 2009 11:09 am

Receive RS232 string

Post by Adrien DG »

Good morning !!
I'd like to receive a string from RS232, but I don't understand what kind of parameters I've to put in the RS232 routine
Example,
If I receive the string "COMPTEUR" from RS232, i send the value of a variable by RS232
Thanks you for your help
Regards,
Adrien DG

User avatar
Steve
Matrix Staff
Posts: 3434
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: Receive RS232 string

Post by Steve »

You should use the "ReceiveRS232String" macro of the RS232 component. There should be some examples of this in the collection of Flowcode examples on the Flowcode CD.

Adrien DG
Posts: 15
Joined: Thu Jun 11, 2009 11:09 am

Re: Receive RS232 string

Post by Adrien DG »

Ok, I've seen it !
Thank you !!
Regards,
Adrien DG

Adrien DG
Posts: 15
Joined: Thu Jun 11, 2009 11:09 am

Re: Receive RS232 string

Post by Adrien DG »

Hello,
I come back to you for my problem of RS232 receive string

I receive a string for example : " TEST "
If the string I receive is "TEST", I send a value, for example 10000
else I send an ERROR message.

I've used the compare() fonction in string manipulation block, but that don't runs...
Could you explain me how can I do it ?

Thant you !!!
Bye
Regards,
Adrien DG

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Receive RS232 string

Post by Benj »

Hello Adrien,

The string manipulation compare function returns a 0 when the strings match. Could this be the problem. I assure you it does work :)

Adrien DG
Posts: 15
Joined: Thu Jun 11, 2009 11:09 am

Re: Receive RS232 string

Post by Adrien DG »

Hello BenJ,
Yes I've seen a French Manual about flowcode, and I saw in it the use of this function

Look at my example,
If I send a "A", and I compare with a "A", I always receive a False
For sure I don't have understood one thing.
Attachments
TEST RS232 - TEST RECEPTION.fcf
(7.5 KiB) Downloaded 317 times
Regards,
Adrien DG

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Receive RS232 string

Post by Benj »

Hello,

It might be worth collecting the length of the string and the contents of the string and echoing these values back also with the RS232 on a Error. This will show you what the microcontroller is seeing as received.

Other then this you can also check single characters from the string one by one using decision icons.

EG

RECEPTION[0] = 'A'

Adrien DG
Posts: 15
Joined: Thu Jun 11, 2009 11:09 am

Re: Receive RS232 string

Post by Adrien DG »

Hello BenJ,
thank you, that runs very well,
but now, I've another question ...
How can I program an Interrupt on the Rx pin ? Using the RXINT ??

Thank you in advance
Regards,
Adrien DG

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Receive RS232 string

Post by Benj »

Hello,

Attached is an interrupt example of your earlier program.

You just need to ensure you use the dummy read component macro to enable the UART receive functionality before the interrupt will start working.
Attachments
TEST RS232 - TEST RECEPTION.fcf
(8 KiB) Downloaded 439 times

Adrien DG
Posts: 15
Joined: Thu Jun 11, 2009 11:09 am

Re: Receive RS232 string

Post by Adrien DG »

Thank you so much BenJ,
I'll try this !!
Regards,
Adrien DG

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Re: Receive RS232 string

Post by jgu1 »

Hi!

I have follow this line. I have a question, What is the "11,11" in the Component Macro under variable?

Thank´s

Regard Jørgen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Receive RS232 string

Post by Benj »

Hello Jorgen.

The 11, 11 are values that are passed to the component macro call as parameters.

Looking at the help file for the component will explain the parameters meaning and role in the function.

The first is the number of iterations to wait before returning a no data received value. This is not needed as we are using the interrupt so you could change this to 1 if you like.

The second is the number of bytes to try and receive into the string variable before a timeout occurs.

Post Reply