INTL 3:770/1 3:770/3   
   REPLYADDR Pancho.Jones@proton.me   
   REPLYTO 3:770/3.0 UUCP   
   MSGID: 34c8f442   
   REPLY: f2e1da15   
   PID: SoupGate-Win32 v1.05   
   On 25/03/2024 15:57, The Natural Philosopher wrote:   
   > On 25/03/2024 11:31, Pancho wrote:   
   >> On 24/03/2024 11:13, The Natural Philosopher wrote:   
   >>   
   >>> However on trawling the internet I discovered a conversation with   
   >>> someone else *on here* (c.s.r-pi) last year, who was finding that   
   >>> *sleep_us(x)* was highly inconsistent for certain (small) values of   
   >>> x. Sometimes taking a day to end.   
   >>>   
   >>> Further investigation reveals that in fact it really is a 'sleep'   
   >>> with the processor being put in low power mode and requiring an   
   >>> interrupt to 'wake it up'.   
   >>>   
   >>   
   >> Why not use threads/timers, wait on a lock/semaphore rather than sleep.   
   >>   
   > Good point Pancho, but I was really looking for the simplest code   
   > possible. Interrupts can be tricky things on a platform whose   
   > architecture you do not understand completely. In any case it was a   
   > learnning curve I preferred not to negotiate if i didnt need to   
   >   
      
   A timer isn't complicated, just a call back routine, and a semaphore.   
   Interrupts are something an OS does, not me :o). I hate multithread   
   code, but async handling of an external resource is one of the two main   
   places I would use another thread.   
      
   I had a look at your code, it looks extraordinarily like a python   
   example on Tom's hardware.   
      
   I'm not clear how many times it is succeeding vs failing, but I suspect   
   you really need to bite the bullet and introduce timeouts/error   
   handling, if it fails try again, average out multiple results. i.e.   
   accept it as flawed and that results are statistical, like GPS.   
      
   In many ways the resilience code will be simple, because it is just   
   normal code, rather than cargo culting a novel ultrasonic device.   
      
   You can investigate further, by recording fail stats, as well as   
   distance stats.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)   
   SEEN-BY: 10/0 1 15/0 90/1 103/705 105/81 106/201 128/260 129/305 135/225   
   SEEN-BY: 153/757 7715 218/0 1 601 700 840 870 930 220/70 221/1 6 226/17   
   SEEN-BY: 226/30 100 227/114 229/110 111 112 113 200 206 307 317 400   
   SEEN-BY: 229/426 428 470 550 616 664 700 240/1120 266/512 267/800   
   SEEN-BY: 282/1038 291/111 292/854 301/1 113 812 310/31 320/219 322/757   
   SEEN-BY: 335/364 341/66 342/200 396/45 460/58 633/280 712/848 770/1   
   SEEN-BY: 770/3 100 330 340 772/210 220 230 5020/400 1042 5058/104   
   SEEN-BY: 5075/35   
   PATH: 770/3 1 218/840 221/6 301/1 218/700 229/426   
      
|