• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bad serial readings after long time of run with Java Comm API

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey there, i was wondering if anyone had dealt with that before or know what the issue may be?

I have an app that make serial readings, append them to a textArea and then, write to MySQL database.
The program runs perfectly, the problem is that after a while, the serial start making bad readings.

Example:
The app reads this:
Weight: 10, Net Weight: 10.23, Tar: 1.85, Date: d/MM/yyyy
Weight: 9, Net Weight: 14.3, Tar: 2.1, Date: d/MM/yyyy

After a while:
Weight: BxT2, Net Weight: PfR4 etc, etc.
Weight: ExT0, Net Weight: GfW3 etc, etc.

Here's my code for the Serial, data available:


my dataBase method just split strings and write into MySQL.

Do you think its the device sending data to the PC or something with the programming?

Any ideas? Thanks!
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code is confusing me a bit, so if possible, i would like to first understand it.

You do

inside your method, right at start, (note that this will run each time a DATA_AVAILABLE event is triggered) and then you do

but you do nothing with data after doing this line. What is the purpose of the concat between data and texto?

Second, while you have the info obtained through the serial reader in data, texto has the content of singleData (considering you manage to run the code, i suppose it is a class attribute). Is this the behavior you were expecting? I would like to point out that you don't do anything with the data actually obtained from the serial reader in any part of your code (besides the 'useless' concat).

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And following on from Daniel's comments, I don't see how

can even compile when you declared "data" as a byte variable.
 
Eder Suarez
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah yes, sorry i had a misstype. Here's the complete serial code:



Now, the PLC sends one line of data with "pauses" so saves the complete string so when the line ends, it has the complete value or the recieved data, then where obviously erases existing data so it can start over again.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too difficult a question for "beginning". Moving thread.
 
Slime does not pay. Always keep your tiny ad dry.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic