Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Seria data manipulation/capture help

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
k_man

Bascom Member



Joined: 10 Apr 2006
Posts: 38
Location: AK

newzealand.gif
PostPosted: Wed Jul 11, 2007 4:20 am    Post subject: Seria data manipulation/capture help Reply with quote

I am using these Bluetooth units.
http://www.sparkfun.com/commerce/product_info.php?products_id=582

AT Command datasheet
http://www.sparkfun.com/datasheets/RF/BlueRadios_ATMP_Commands_Rev_3.5.2.1.4.0.pdf

I wasn't sure what serarch terms to use so could not do my usual exhaustive search before asking Smile


Basically I want to capture each address the query returns.
I can grab the first one but don't know the most efficient way to grab the rest.
And prehaps a timeout routine.



The serial transaction looks like this
Code:

19:02:56.87 [TX] - atdi,5,00000000<cr>

19:02:57.04 [RX] - <cr><lf>
OK<cr><lf>
<cr><lf>
000A3A66C0E6,00320104<cr><lf>
<cr><lf>
000A3A66C0E7,00320104<cr><lf>
<cr><lf>
000A3A66C0E8,00320104<cr><lf>
<cr><lf>
000A3A66C0E9,00320104<cr><lf>
<cr><lf>
DONE<cr><lf>
<cr><lf>
19:03:37.38 [TX] - ATRRN,000A3A66C0E6<cr>

19:03:37.52 [RX] - <cr><lf>
OK<cr><lf>
<cr><lf>
WORKSHOP<cr><lf>
<cr><lf>
 



The program I have so far.
It is not pretty so be gentle Smile

Code:

$regfile = "attiny2313.dat"
$crystal = 8000000
$baud = 9600
$hwstack = 32
$swstack = 32
$framesize = 32

'          ----
'     Rst |1xx0| Vcc
'Rxd  Pd0 |2 x9| Pb7
'txd  Pd1 |3 x8| Pb6
'     Pa1 |4?x7| Pb5
'Upd  Pa0 |5? 6| Pb4
'     Pd2 |6  5| Pb3
'     Pd3 |7  4| Pb2
'     Pd4 |8  3| Pb1
'     Pd5 |9  2| Pb0
'     Gnd |0x 1| Pd6
'          ----

Config Porta.0 = Output
Upd Alias Porta.0

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Dim Var_counter1 As Byte
Dim Var_serial_chr As Byte
Dim Var_input_string_1 As String * 13
Dim Var_done As Byte
Dim Var_friendly_name_1 As String * 4


'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Const Con_serial_chr_stop_1 = 44
'comma ,
Const Con_serial_chr_cr = 13
'CR
Const Con_serial_chr_lf = 10
'LF
Const Con_start_delay = 2
's
Const Con_string_length = 13
's



'------------------------------------------------------------
Main:
      Wait Con_start_delay


Discover:
      Var_input_string_1 = ""
      Print "ATDI,1,00000000"
   Gosub Sub_wait_for_crlf
   Gosub Sub_wait_for_crlf
   Gosub Sub_wait_for_crlf


Read_addresse1:
      Var_serial_chr = Waitkey()
   If Var_serial_chr = Con_serial_chr_stop_1 Then Goto Read_addresse1_end
   If Var_serial_chr = Con_serial_chr_cr Then Goto Read_addresse1_end
'checks for comma - or cr when no devices found
      Var_input_string_1 = Var_input_string_1 + Chr(var_serial_chr)
   Goto Read_addresse1

Read_addresse1_end:
   If Var_serial_chr = Con_serial_chr_cr Then Goto Main

   Gosub Sub_wait_for_crlf

      Wait 8


Get_friendly_names:
      Print "atrrn," ; Var_input_string_1
   Gosub Sub_wait_for_crlf
   Gosub Sub_wait_for_crlf
   Gosub Sub_wait_for_crlf
   Gosub Sub_wait_for_crlf
      Var_input_string_1 = ""


   For Var_counter1 = 1 To 4
'Only store first 4 characters of name
   Var_serial_chr = Waitkey()
      Var_input_string_1 = Var_input_string_1 + Chr(var_serial_chr)

   Next Var_counter1

      Print "Friendly_name=" ; Var_input_string_1

   Wait 5
   Goto Main


'-----------Subs
Sub_wait_for_crlf:

Wait_for_cr:
      Var_serial_chr = Waitkey()
   If Var_serial_chr = Con_serial_chr_cr Then Goto Wait_for_cr_end
   Goto Wait_for_cr
Wait_for_cr_end:

Wait_for_lf:
      Var_serial_chr = Waitkey()
   If Var_serial_chr = Con_serial_chr_lf Then Goto Wait_for_lf_end
   Goto Wait_for_cr

Wait_for_lf_end:

Return
 
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum