I am posting this to both the comm-dev-forum and to palm-dev because it has relevant issues both relating to the operating system in general and to the serial communications, specifically on the TungstenC.
PROBLEM:
Our software communicates with a our own proprietary hardware device via the serial port on the unit. Our hardware is an RF receiver that operates at ~433mhz. When the palm unit is on, it creates a lot of noise, which makes our receiver much less sensitive (with regards to range). To alleviate this, I programmatically turn the unit off for X number of seconds and then I turn it back on, poll our device, and then turn the palm unit back off. This allows our receiver to pick up any transmissions from our outlying RF transmitters while the palm unit is off. The problem is that by doing this, I am agitating the UART in the Tungsten C and it disables itself. Once this happens, I must leave my app (closing the serial port) and renter it (opening the serial port). Eventually, the problem will get so bad that hard resetting the device is the only way to get the serial port to act properly again.
[For the software guys]
To accomplish shutting the down the palm unit and turning it on. I do the following:
Waking up: I register for the sysNotifySleepNotifyEvent. Whenever I receive this notification, I set an alarm for X number of seconds later than the current time. I also register for the sysNotifyLateWakeupEvent. In this event, I simply check to see if the current timestamp is before the next alarm is scheduled. If this is the case, I tell my code to NOT go back to sleep. If the current timestamp is greater than or equal to my last set alarm time, then I assume that the device wakeup based on the alarm and tell it to go back to sleep.
Going to sleep: I put the device to sleep using the following line of code.
EvtEnqueueKey( vchrPowerOff, 0, commandKeyMask );
My understanding is that by posting this key, the system has a chance to go to sleep properly.
After I finish querying our device, I check the flag that I set in my sysNotifyLateWakeupEvent handler, and if it is set, I put the device back to sleep, which causes the cycle to repeats (i.e. I receive the sleep notification, ...).
Please let me know if you see something in this logic that would cause the system to go to sleep or to wakeup in an invalid state.
[For the hardware guys]:
The problem that I am about to explain happens on a TungstenC, but not on an m515.
I only open the serial port when the app starts and I close it when the application has exited. In normal operation, if the Tungsten C goes to sleep based on the timeout period set in the preferences and I turn it back on by pressing the power button, my applications starts back up and there is no problem. However, if I put the device to sleep (as explained above) when the device wakes up the serial port works properly for about a half of a second and then seems to disable itself. This is an interesting problem because the time it takes for the palm unit to wakeup, me to poll our device, and to put the unit back to sleep, it appears that everything works fine (the serial port does not have time to display the problem). However, if I programatically put the device to sleep and then manually wake it up by physically pressing the "on" button, the serial port wakes up for a half seconds (long enough for me to send a couple of requests to our device) and then it disables itself. The reason I say that it is disabled is because the TX line from the unit falls from 5V (idle) to 0V indefinitely. Once this happens, I must exit our application and reenter it (which causes the serial port to close and reopen).
I did a lot of testing trying to narrow down the issue, and here is what I found. First, I thought that maybe I was waking the device up and putting it to sleep too quickly. I put a SysTaskDelay( 2 seconds ) in to the code once the device has woken up. This did not fix anything. I also tried closing the serial port when the device goes to sleep and opening it back up when the device wakes up. This did not solve the problem either. I noticed on the m515 that even if I set the alarm to go off 20 seconds after it goes to sleep, the device does not wakeup for about a minute (or on a minute boundary on its internal clock). The TungstenC wakes up immediately. So, I set the tungsten to wakeup after a minute and that also did not fix the problem
So, my very long winded question is. Has anyone encountered this problem? And, am I doing something obvious that would cause the TungstenC's UART to freak out?
Thanks for taking the time to read this post!
Brad
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
