Hserin / out Woes..


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624

    Default Re: Hserin / out Woes..

    Hi,
    I'm not sure if the DEFINE HSER_BAUD accepts non standard baudrates, I suspect it does since it kind of works. What's with the 9615 anyway?
    I don't know what would make it fail on the last character - sometimes. Are you typing in, and sending, the characters one by one, ie there's 100ms or whatever between each character?

    Anyway, here's an alternative aproach I just wrote. I have not tested it, not even compiled it so take it for what it is.

    Code:
    Key VAR BYTE
    CorrectKey VAR BYTE[9]
    KeyIndex VAR BYTE
    PassFail VAR BIT
    
    Pass CON 1
    Fail CON 0
    
    CorrectKey[0] = "2"
    CorrectKey[1] = "9"
    CorrectKey[2] = "9"
    CorrectKey[3] = "7"
    CorrectKey[4] = "9"
    CorrectKey[5] = "2"
    CorrectKey[6] = "4"
    CorrectKey[7] = "5"
    CorrectKey[8] = "8"
    
    
    Main:
    hserout [":- "]
    
    PassFail = Pass
    For KeyIndex = 0 to 8
    	HSERIN 65535, bed, Key
    	HSEROUT Key
    	IF Key <> CorrectKey[KeyIndex] THEN
    		PassFail = Fail
    	ENDIF
    NEXT
    
    IF PassFail = Pass THEN
    	HSEROUT[10, 13, "Correct key entered",10, 13]
    ELSE
    	HSEROUT[10, 13, "Wrong key entered", 10, 13]
    ENDIF
    /Henrik.

  2. #2
    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

  3. #3
    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

  4. #4
    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 !

  5. #5
    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

  6. #6
    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

  7. #7
    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

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