Hi. I want to do OTG serial monitor. I have a problem. I just want to see last 10 line data on the label. But i can't do that. My code is;
Can you help me?
Hi. I want to do OTG serial monitor. I have a problem. I just want to see last 10 line data on the label. But i can't do that. My code is;
Can you help me?
Hi Yasin
Use a Block List and display in a ListView instead, then your 'lines' are List Items. Once the List is has Items and data line 11 is received, you can delete the first Item, append the new line, repopulate the ListView.
Hi, i,m the new to devolop android application. Can you give me an example?
Thank you, it worked
Now, i have a new problem, i dont want to add "\n" every getting data. when i get "\n" from serial, i want to put \n, can you help me? My code;
Let me see if I get this requirement right.
You want to build up a line of input until it contains '\n' somewhere in it, and
only then do you want to start a new line?
This should work, if my multiline text box allows \n entry ...
last_ten_text.aia (2.7 KB)
I have unexplained red and yellow errors in the Blocks Editor, so tell me if they propagated to you in the .aia file or the Blocks PNG.
Warning - my project is corrupted, probably because of my repeated unsuccessful attempts to drag the OP's blocks into my project.
Don't try to drag them into your project(s).
Hello, I am sending data from the computer to the phone via serial port. If there is "\n" in the data I sent, I want to add a new line. Otherwise, I want to continue on the same line.
For example;
İf i send "abc" 5 times from the computer, i want to see;
abcabcabcabcabc
and if i send "abc\n" 5 times, i want to see;
abc
abc
abc
abc
abc
When i use your code, i see;
abc
abc
abc
abc
abc
And my total line number is increasing every getting data.
Please export your project and post it here.
Since I can't see your data stream directly, here's a patch to eliminate blank lines ...
replace all '\n\n' with '\n'
Hi, i added my project. my data can be everything. i want to read every string, if it has or hasn't cr+lf, if has cr+lf, i want to use it my text label for new line or carriage return. you can create your own data. my project;
Hyperterminal.aia (195.9 KB)
I remembered a past issue with reading back Label or Textbox .Text values into AI2, where \n might be changed into \r\n values, so I changed my logic into using a new global variable as the text buffer that will accumulate all the input, occasionally scrubbing all \r and replacing \n\n with \n. My split technique might fail if the \n is at the end of the buffer. Please test it.
Hyperterminal (1).aia (196.5 KB)
P.S. Cross language translation might be messing up global variable inits.
Thanks for your help. i tried it but "gelen1.Text" is empty now.
Reading my blocks, I see no place where I remove non-whitespace text from the global buffer variable.
Either there is no data arriving, or crossing the boundary between English and your language has messed with the global variable names.
This would be a good time to use the Companion and apply a Do It to the global buffer variable.
OK, thanks, if i solve this problem, i will share my solution.
Here is another simplification for you, to help debug.
The test for an empty input (veriler) is not needed.
Empty inputs are harmless, since JOINING them to the input buffer changes nothing.
Removing the if/then test for blank input will have the benefit of removing another obstacle to refreshing the output label from the global buffer variable.
I mention this because there is a bug in the text 'not equal' comparison block that makes it return false under certain circumstances when it should return true. Eliminating the green equality test reduces the error probabilities.