Android Basic Alternative


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    Use this line

    AStream.InitializePrefix(serial1.InputStream, False, serial1.OutputStream, "AStream")

    instead of

    AStream.InitializePrefix(Main.serial1.InputStream, True, Main.serial1.OutputStream, "AStream")

    The False part I bet fixes your problem.

  2. #2
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    Quote Originally Posted by Tobias View Post
    Use this line

    AStream.InitializePrefix(serial1.InputStream, False, serial1.OutputStream, "AStream")
    I finally found time this weekend to play with this some more and did get it working! Thanks for your help Tobias!
    Shawn

  3. #3
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    My very simple working code:

    Code:
    OSCCON=%01110000            ' SET TO 8 MHZ internal oscillator
    DEFINE OSC 08               ' 8MHZ clock speed 
    DEFINE HSER_BAUD  9600      ' Set baud rate
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_CLROERR 1       ' Clear overrun error upon
    DEFINE HSER_TXSTA 24h       ' Set transmit status and control register
    DEFINE HSER_SPBRG 51        ' 9600 Bauds
    
    RPM      var word
    SPEED    var word
    TPS      var byte
    volts    var byte
    adc1     var word
    adc2     var word
    prefix1  var byte    
    prefix2  var byte
    prefix3  var byte
    prefix4  var byte
    
    rpm     = 3800
    speed   = 60
    tps     = 10
    volts   = 122
    ADC1    = 512
    ADC2    = 200
    Prefix1 = 22  
    Prefix2 = 0
    Prefix3 = 0
    Prefix4 = 0
    
    main:
      pause 500
      hserout [Prefix1,Prefix2,Prefix3,Prefix4,dec5 rpm, dec3 speed, dec3 TPS, dec3 volts, dec4 adc1, dec4 adc2] 
    goto main  
    
    end
    Code:
    Sub Process_Globals
    	Dim AStream As AsyncStreams	
    	Dim Incoming As String
    	Dim RPM As Int 
    	Dim SPEED As Int 
    	Dim TPS	As Double 
    	Dim VOLTS As Int 
    	Dim ADC1 As Int
    	Dim ADC2 As Int 
    End Sub
    
    Sub Activity_Create(FirstTime As Boolean)
    	Activity.LoadLayout("2")
    	  If AStream.IsInitialized = False Then	
    		AStream.InitializePrefix(Main.Serial1.InputStream, False, Main.Serial1.OutputStream, "AStream") 
    	  End If
    	Update_Display 
    End Sub
    
    Sub AStream_NewData (Buffer() As Byte)
    	Log( BytesToString(Buffer, 0, Buffer.Length, "ISO8859_1"))
    	Incoming = BytesToString(Buffer, 0, Buffer.Length, "ISO8859_1")
    	
    	RPM   = (Incoming.SubString2(0,5))
    	SPEED = (Incoming.SubString2(5,8))
    	TPS   = (Incoming.SubString2(8,11))
    	VOLTS = (Incoming.SubString2(11,14))	
    	ADC1  = (Incoming.SubString2(14,18))
    	ADC2  = (Incoming.SubString2(18,22))
    
    	Update_Display 
    End Sub
    Shawn

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    Thanks for the working example. Can you explain the complete setup? That HSEROUT goes to what, an external bluetooth module?

    This would make an excellent article with some narrative explaining what is going on, hardware/software requirements, etc.

    Robert

  5. #5
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    The hserout goes to a RN42 bluetooth modem. Could be done with debug as shown in an earlier post. Once paired it isn't much different than any other serial connection, but the Android side of things takes some time to wrap your head around. The prefix is a pain, but works very well once working. It is basically just a 32 bit header detailing the number of bytes in the serial string.
    Shawn

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    Can we control to what device we want to talk to via that header?

    Let's say to transmit one thing to my cell phone and another to my daughter's?

  7. #7
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    No, what you transmit to is strictly set by pairing the 2 devices which is not part of this code. I don't think you can pair more than 2 devices. The header is just for validation of the data. The data received flag isn't raised until all data is received, without it the flag is raised as soon as data appears, and then you have to manually put the bytes into a string and wait until they all arrive.
    Shawn

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    Good to hear you got it sorted out.

    I have to say if you are turning 3800 at 60MPH, you might need to look at changing rear gears

    Quote Originally Posted by spcw1234 View Post
    I finally found time this weekend to play with this some more and did get it working! Thanks for your help Tobias!

  9. #9
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    Just thought I should bring this thread up to date... In the end I gave up on the alternatives, and I broke down and bought Basic4Android since it seems to be the most mature thing out there. If anybody is interested in a 50% off coupon code, you can use this " dqqshs " You go to their purchase page and hit the "Plimus" button, then enter the code.

  10. #10
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Android Basic Alternative

    I'm debating which version to get, Enterprise $99 at 50%?

    Bang for buck looks good.

    Which are you getting?

    (Just checking so I can copy your code )

    Robert

Similar Threads

  1. Android Basic
    By dhouston in forum Off Topic
    Replies: 14
    Last Post: - 16th February 2013, 02:47
  2. Pic to Android
    By l_gaminde in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th January 2012, 19:08
  3. PBP & Android Interfacing
    By lester in forum PBP & Amicus18
    Replies: 5
    Last Post: - 13th May 2011, 22:41
  4. PICs and Android
    By ardhuru in forum General
    Replies: 3
    Last Post: - 17th November 2010, 06:41
  5. Pulsin alternative
    By sbobowski in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th October 2008, 09:21

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