how can i monitor the serial port for reading

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
zhanghuanqian
Posts: 20
Joined: Sat Jan 24, 2015 2:27 pm

how can i monitor the serial port for reading

Post by zhanghuanqian » Mon Jan 18, 2016 12:05 pm

hello:
I want to read arduino board by serial port. And how can I monitor when the buffer has some data arrived? I try it by "wait for 3000 milliseconds", but I loss some data. how can I get total data?
thanks!
Last edited by zhanghuanqian on Tue Jan 19, 2016 2:44 am, edited 1 time in total.

zhanghuanqian
Posts: 20
Joined: Sat Jan 24, 2015 2:27 pm

Re: how can i monitor the serial port for reading

Post by zhanghuanqian » Mon Jan 18, 2016 1:25 pm

Code: Select all

open driver "COM5:" for binary update
wait for 3000 milliseconds//if read directly, it will get nothing because Arduino will restart after a cup of and then send data by serial port
read from "COM5:" for 128 uInt1
put it//it can get part of data , not all data
close driver "COM5:"
And, the progress not know when the datas are sended by Arduino board.
so, how can i monitor the serial port for the comming datas and read them crectly?
thanks!
Last edited by zhanghuanqian on Tue Jan 19, 2016 2:46 am, edited 1 time in total.

zhanghuanqian
Posts: 20
Joined: Sat Jan 24, 2015 2:27 pm

Re: how can i monitor the serial port for reading

Post by zhanghuanqian » Tue Jan 19, 2016 2:42 am

My Arduino board send a number every 100 milliseconds from 0 to 65535, but the LC process read the data like "50 48 51 57 51" ,it is not right!
Is it a interrupt or another methods to monitor whether the data is send by Arduino or not?

zhanghuanqian
Posts: 20
Joined: Sat Jan 24, 2015 2:27 pm

Re: how can i monitor the serial port for reading

Post by zhanghuanqian » Wed Jan 20, 2016 10:18 am

I fond a thread here:http://forums.livecode.com/viewtopic.ph ... er#p123143

I try it ,but Unstable!

zhanghuanqian
Posts: 20
Joined: Sat Jan 24, 2015 2:27 pm

Re: how can i monitor the serial port for reading

Post by zhanghuanqian » Fri Jan 22, 2016 7:28 am

mm, perhaps it is not clearly.
I write a program by LC7.0(os:win 7) to read the data sent by Arduino board, the data is large and random. So I cant deal with it.

mexicanto
Posts: 6
Joined: Mon Mar 17, 2014 3:57 pm

Re: how can i monitor the serial port for reading

Post by mexicanto » Fri Feb 12, 2016 10:17 am

Check this two files
I made this about a year ago, and i uploaded to facebook, livecode latinamerican group
hope this can help you

the two files (arduino and LC) are the ones with the name full_control_01

www facebook com/groups/livecodela/files/

just add the dots in the right place in the web address

zhanghuanqian
Posts: 20
Joined: Sat Jan 24, 2015 2:27 pm

Re: how can i monitor the serial port for reading

Post by zhanghuanqian » Sun Feb 14, 2016 1:34 pm

thanks very much!

mexicanto
Posts: 6
Joined: Mon Mar 17, 2014 3:57 pm

Re: how can i monitor the serial port for reading

Post by mexicanto » Mon Feb 15, 2016 6:23 am

You are welcome

Please, let me know your experience working with the codes


Another thing, i recommend you to start playing with the ESP8266 module, is like arduino, but wifi, that means, no cables attached!

Post Reply