Hserin / out Woes..


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229

    Default Re: Hserin / out Woes..

    Here is another approach that allows you to wait for all of the characters to be entered before testing the password.
    It also makes use of arraywrite to enter the Master Password.

    Code:
     DEFINE OSC 4	'Set oscillator in MHz
        'OSCCON = $60     '4 Megs
        
        DEFINE HSER_RCSTA 90H   'Set receive status and control
        DEFINE HSER_TXSTA 24H   'Set transmit status and control
        DEFINE HSER_BAUD 9615   'Baud Rate
    
    MasterPass var byte[9]
    pass var byte[9]
    PassTest var bit
        
    i var byte
        
    '    ADCON1 = 7 ' Turns Analogs off
    '    CMCON0 = 7 'Disable both comparators
    '    ANSEL = 0  ' Set all analog pins to digital
        
        arraywrite MasterPass,["299792458"]
    
    main:    
        'Test for 299792458
        PassTest = 1
        for i = 0 to 8
            pass[i] = 0
        next i
        
        hserout [":- "] 
        for i = 0 to 8
            hserin 65535, bed, [pass(i)]
            hserout [pass(i)]
        next i
        
        'Check Password with Master
        for i = 0 to 8
            if pass(i) <> MasterPass(i) then PassTest = 0 
        next i
    
        if PassTest = 1 then correct
        
        hserout [13,10,"NO WAY!!",13,10]
        
        
        goto main
    
    
     
    correct:
    
        hserout [13,10,"Correct!",13,10]
        
        goto main
    
                
    bed:
        hserout ["Timeout",13,10]
        
                
     bye:
            goto main
    Regards,
    TABSoft

  2. #2
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Default Re: Hserin / out Woes..

    Thanks for the replies.....

    Will try then out later.... have been working away!

    BR
    Andy

  3. #3
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Default Re: Hserin / out Woes..

    hi All...

    Have played with my code a little more....

    Have come to conclusion that the serial port is seeing 0xFf before I type any password... I found by putting a 232 sniffer on the ports !!!


    Ie the password is 9 chars but the first on occasionally is 0xFF ????

    any Ideas ? anyone ?

    Tomorrow O will go back to Serin / Serout see how that gets on !

    Thank you for help !

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default Re: Hserin / out Woes..

    For reliable communications, I always clear the receive buffer before transmitting a request to any perif. That way if you have some noise on the comm lines, it won't be interpreted as bad data.
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Default Re: Hserin / out Woes..

    Quote Originally Posted by Dave View Post
    For reliable communications, I always clear the receive buffer before transmitting a request to any perif. That way if you have some noise on the comm lines, it won't be interpreted as bad data.
    Hi Dave

    Sounds good.... But how do I do that ?

    I see no pointers in the manual V2.60

    THank you for help

  6. #6
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Default Re: Hserin / out Woes..

    MY Defines are now :-

    DEFINE HSER_RCSTA 90H 'Set receive status and control
    DEFINE HSER_TXSTA 24H 'Set transmit status and control
    DEFINE HSER_BAUD 9615 'Baud Rate
    DEFINE HSER_CLROERR 1 ' Clear Buffer

  7. #7
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229

    Default Re: Hserin / out Woes..

    Andy,

    You can always just use a "HSERIN" bogus statement to throw away anything in the buffer before you execute your regular "HSERIN" statements.
    Since the EUSART has a 2 byte buffer you may need to do two of the bogus "HSERIN" statements with timeouts just to make sure you don't get stuck waiting.
    Regards,
    TABSoft

Similar Threads

  1. SPI woes
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th September 2013, 15:04
  2. Capture woes...
    By ardhuru in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 22nd May 2011, 09:36
  3. LCDOut Woes
    By LetTheSmokeOut in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 11th June 2008, 02:45
  4. ICD Woes
    By spad13m in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 14th February 2008, 06:56
  5. Still HSEROUT woes
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 11th July 2006, 22:13

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts