Trouble with Serin2 and variable size


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default

    A couple of things about what you have.

    First off holder=0 doesn't really do anything. I would suspect you were hoping it would make all the bytes 0 in the array. That isn't the case. You would need to create a loop that places a zero in each byte of the array. Second, you don't have a timeout. Without a timeout, you run the real possibility the code will stall.

    I altered the code to address some of the issues you are running into. Keep in mind there are a least 3 different ways (maybe more) to accomplish what you are asking. It’s really a matter of style and application, neither of which I can decide for you. In this version of the code, I added length and command. Command handles the command portion of LCDOut (see manual). Length tells the string command when to stop. This should eliminate the blocks. Using this approach, you need to expand the string you are sending from the stamp. (See below) If you didn’t want to specify a length you would need to create a loop to collect the data byte by byte and then use the terminating character that was in the code before. Here again both work, it depends on style and application. Enjoy.

    Code:
    Holder var byte[20]
    Length var byte
    Command var byte
    
    main:
    serin2 PORTB.0, 16780, Data_Error,[Command, Length ,STR holder\20\Length] 
    LCDOUT $FE,Command, STR holder\Length
    goto main
    
    BS2p Pbasic Code:
    
    Start:
    SEROUT 0,17405, [1,5,"hello"]  ‘ 1=LCD Clear, 5=Length of hello
    PAUSE 1000
    GOTO Start
    In regards to HSERIN, like the rest of us you will eventually run into a problem and you will need to use hserin to solve it. Usually this occurs when your code starts doing other things and polling for serial data becomes impractical. We all get there at some point.
    Last edited by DynamoBen; - 5th October 2006 at 16:48.

Similar Threads

  1. Getting SERIN2 to work?
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 22nd July 2009, 20:10
  2. Serin #Variable question
    By bluesmoke in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 7th July 2009, 17:48
  3. Yet another SERIN2 question
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 31st March 2009, 20:11
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Help with STR ArrayVar\n\c with SerIn2
    By leinske in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 15th May 2006, 01:04

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