Pages: [1]   Go Down
Author Topic: SoftwareSerial timeout  (Read 969 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

After searching the forums for some time, I've found pieces here and there talking about this, but nothing with a straight up answer... so I'm starting a new thread.

I'm using SoftwareSerial in my projects, and it's working wonderfully - until of coarse the device I'm talking too gets unplugged from power or unplugged from the arduino....

Then whenever my loop goes to fetch data from the softwareSerial (read) connection - it hangs forever.  Which this was documented that this is correct behavior - but I am curious if someone has figured a way to have it timeout if no data is present.  Sort of like the SerialAvailable command for the Hardware Serial connection - but probably more along the lines of a 5 second timeout if no data is present sort of thing.

Thanks in advance for any time/expertise.
Logged

"The early bird may get the worm, but it's the second mouse that gets the cheese!"

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

hmmmm....  

Does my question not make sense?  Or is nobody else running into this issue?

Thanks all for any input/insight/work-arounds etc.

 :-/
Logged

"The early bird may get the worm, but it's the second mouse that gets the cheese!"

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This isn't really an issue. It's working as it is designed to work. If you need it to work in a different way you can either use a different library or hack this one. I can't help you with either of those things (I'm very new to computing at this level) but I'm fairly sure this library as it is won't do it for you.

Charlieb
Logged

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

I realize this is correct behavior, just looking for some guidance on working around it.  Has anyone experimented with this before?

Thanks Charlie for your reply.
Logged

"The early bird may get the worm, but it's the second mouse that gets the cheese!"

0
Offline Offline
God Member
*****
Karma: 0
Posts: 731
skcor oniudrA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
hmmmm....  

Does my question not make sense?  Or is nobody else running into this issue?

Thanks all for any input/insight/work-arounds etc.

 :-/

Your question makes perfect sense, software serial doesn't have serial.available, so when you break a loop to check a device, there is no way to get back to that loop unless the device does something.

There should be a "BIG sticky" about this on the SS page, because unless you know about the missing serial.available function, and what it implies, an enormous amount of time can be wasted implementing it.

The solution we're throwing around at the moment, is porting to ATMEGA128 and the wiring board, or, using I2C, which does have a .available function.



Logged

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

Yeah, I knew the Software Serial lib didn't have an 'available' feature, I didn't think it would turn into an issue.  However, it did.

I also ended up having other problems, my program was teetering around the 8K mark, and would get sporatic when I added any more code, and more stable when I took a couple lines away.

So I ended up getting a couple wiring boards.  So far i love them.  128K of space for program, nice.  Also, it has two hardware serial ports.  Allowing me to leave it plugged into the computer as well as the device (lcd projector) at the same time.  Lovin' it.

I'm still tinkering with modifying the Software Serial library though.  Will post if anything comes of it.
Logged

"The early bird may get the worm, but it's the second mouse that gets the cheese!"

Sacramento, CA, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been playing around with the SS library.  I'm pretty new to the arduino platform, but it looks like there is surely room for improvement with the SS library.  I've been meaning to add basic things like a timeout.  This really shouldn't be all that hard.  If you want to give it a go, I'm sure you can make it work for you.  Otherwise, I plan on getting around to this sometime soon.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Any improvements you can make to the SoftwareSerial library would be much appreciated.  It needs some love, and I haven't had time to work on it.
Logged

Pages: [1]   Go Up
Jump to: