Pages: [1]   Go Down
Author Topic: Storing incoming data from serial port  (Read 440 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey!!

I have some data coming in from the serial port and i want to manipulate the data further only i have no idea how to store/save the incoming data so i can further use it in the program.

Any suggestions would be highly appreciated.
Thanks in advance
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 179
Posts: 8070
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It depends on how large a chunk of data you are manipulating.

If you are changing each character individually, don't store the data.

If you have a little data, say a line of characters at a time, store it in an array (SRAM), manipulate that line, and send it out.

If you have a LOT of data, say several thousand characters, you can store them on an SD card (you will need to add hardware).  Then you can read and write the SD card.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For some reason when i try to store the data in an array, lots of spaces get included. Can u tell me what i'm doing wrong??
I'm attaching the code i'm using before and after.

Any help would be great.
Thanks in advance

* after.txt (0.62 KB - downloaded 10 times.)
* before.txt (0.48 KB - downloaded 8 times.)
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 439
Posts: 23728
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

These only look to see if you have more than 0 bytes (i.e. 1), but then write out 51 bytes.
Change the code to only write a byte into array when one has come in, increment a counter to stop writing data in when 50 bytes have been received.

  if (mySerial.available())
    Serial.write(mySerial.read());

  if (Serial.available()>0)
    {
      for (i=0; i<51; i++)
      outputs = Serial.read();
     }
   
   for (i=0; i<51; i++)
   Serial.println(outputs);

}
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh ya!! LOL!! Thankyou so much!!!!  smiley  smiley
Logged

Pages: [1]   Go Up
Jump to: