Page 1 of 1
how can I fill an array with RS232 data?
Posted: Tue Apr 26, 2011 2:52 pm
by Rolf1402
Hi,
I'm new to this and need your help!
I currently work on a project where I via the RS232 a lot of data (20 byte's) receive, but the details are not all needed.
My problem is that I would just like the last 6 Bytes Received's use. I thought I'd write the 20 byte's into an array,
then I would have all available individually.
The question is how can I fill an array with RS232 data?
Rolf
Re: how can I fill an array with RS232 data?
Posted: Tue Apr 26, 2011 4:55 pm
by Spanish_dude
Use the RS232 component from Flowcode and read 20 bytes, that's it ^^.
Don't forget that the RS232 data needs to be "converted" to a TTL data. If you don't do this, you can throw your microcontroller away as it won't work anymore, like I did, once ...
Re: how can I fill an array with RS232 data?
Posted: Tue Apr 26, 2011 5:17 pm
by Benj
Hello,
Alternatively you could create a loop to run 14 times with a single RS232 read byte inside, after the loop read the RS232 another 6 times to collect the data you require. This way you only have to store the data you need.
Re: how can I fill an array with RS232 data?
Posted: Tue Apr 26, 2011 6:10 pm
by Rolf1402
Thanks for the quick reply. The loop worked immediately.
Could you tell me how I now save the 6 remaining bytes to go.
Thanks in advance
Sorry this text is form a translator

Re: how can I fill an array with RS232 data?
Posted: Tue Apr 26, 2011 6:45 pm
by Rolf1402
sorry, does not work as I thought. The data I receive from view as follows.
LED on
F5 FF 57 F7 5F 55 D5 D5 D5 57 57 7F 55 55 D5 57 75 FD F5 7D
LED off
F5 FF 57 F7 5F 55 D5 D5 D5 57 57 7F 55 55 55 D7 F5 FF F5 7D
here you can see that the first 14 bytes are always the same.
The only change is the last 6 bytes.
Re: how can I fill an array with RS232 data?
Posted: Tue Apr 26, 2011 9:09 pm
by Spanish_dude
U kunt gebruik maken van een "tabel" of array.
Bekijk de help-files van Flowcode om te zien hoe dat ze die maken.
Code: Select all
char array[6] = {0}; // dit is een tabel van 6 bytes
Om de verschillende bytes in het tabel te kunnen inlezen of schrijven moet u gewoon het getal tussen de vierkante haakjes veranderen.
Deze is nu ingesteld op 6, d.w.z. dat het tabel van array[0] tot array[5] gaat.
Bij het inlezen van de 6 laatste bytes, maak gebruik van een lus en een teller (ingesteld op 0).
U leest het data in en schrijft het in "array[teller]". Dit gaat het ingelezen data "opslaan" in u tabel.
Na dat u een byte ingelezen hebt moet u de teller met één optellen.
Nu moet u gewoon (in het lus nog altijd) het teller vergelijken met 6, als deze 6 (of groter) is dan moet u uit de lus komen.
----
You'll need to use an array to store de 6 bytes you want.
Look at the help files, they'll tell you how to make an array.
Code: Select all
char array[6] = {0}; // an array of 6 bytes
Use a loop and a "counter". Each time you read a data from the RS232, store it in the array and increase counter with one.
Once the counter is equal to 6, get out of the loop and start again (I suppose).
Re: how can I fill an array with RS232 data?
Posted: Wed Apr 27, 2011 1:02 pm
by Rolf1402
I'm totally confused.

Since this morning I have concentrated on the filling of array's, but again without success.
It would be really nice if someone could tell me how I can implement the following routine in my top gepost project and Flowcode.
int array [incom];
for (int i = 0; i <incom; + + i)
Re: how can I fill an array with RS232 data?
Posted: Wed Apr 27, 2011 6:58 pm
by Spanish_dude
Make a new variable named 'i' and another one named 'array[X]'. X is the size of the array, it needs to be a value, not another variable.
Then use a while (i < incom) and add a calculation icon with "i = i + 1" in it.
PS: Do you speak Dutch or am I wrong thinking you do ?
Re: how can I fill an array with RS232 data?
Posted: Wed Apr 27, 2011 7:14 pm
by Rolf1402
Spanish_dude wrote:Make a new variable named 'i' and another one named 'array[X]'. X is the size of the array, it needs to be a value, not another variable.
Then use a while (i < incom) and add a calculation icon with "i = i + 1" in it.
PS: Do you speak Dutch or am I wrong thinking you do ?
Thanks for your tips. This I really need. I'm really new to flow code and have the Pro version only since Friday
I'm German, I thought so as you answered in Dutch
Re: how can I fill an array with RS232 data?
Posted: Wed Apr 27, 2011 7:48 pm
by Spanish_dude
Rolf1402 wrote:I'm German, I thought so as you answered in Dutch
My bad, I saw "eigen_test" on your flowcode file name

.
Learning a bit of C programming will help you alot in making programs with flowcode.
Re: how can I fill an array with RS232 data?
Posted: Fri Apr 29, 2011 4:57 pm
by Rolf1402
Spanish_dude wrote:Rolf1402 wrote:I'm German, I thought so as you answered in Dutch
My bad, I saw "eigen_test" on your flowcode file name

.
Learning a bit of C programming will help you alot in making programs with flowcode.
It seems to be very difficult to fill an array via the RS232. In my books It will only explain how I fill the array in C program, but not USART or UART
Re: how can I fill an array with RS232 data?
Posted: Tue May 03, 2011 10:24 am
by Benj
Hello,
Its very simple. Here is a quick program that reads data from the RS232 and stores into an array until a time out is received or the array is filled. The array is then sent back out over the RS232.
Re: how can I fill an array with RS232 data?
Posted: Tue May 03, 2011 1:54 pm
by Rolf1402
Benj wrote:Hello,
Its very simple. Here is a quick program that reads data from the RS232 and stores into an array until a time out is received or the array is filled. The array is then sent back out over the RS232.
This is exactly what I need
Thank you so much
