Shop OBEX P1 Docs P2 Docs Learn Events
problem about code — Parallax Forums

problem about code

hannibal8hannibal8 Posts: 1
edited 2009-06-26 18:00 in Learn with BlocklyProp
[size=2][code]
[color=green]' {$STAMP BS2e}
' {$PBASIC 2.5}
'
'================================================= ======[/color]
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T2400 CON 396
T4800 CON 188
T9600 CON 84
T19K2 CON 32
#ENDSELECT
[color=green]'-------------------------------------------------------
' I/O Definitions
'-------------------------------------------------------[/color]
 TX PIN 0'Serial Transmit line from eb500-SER
 RX PIN 1'Serial Receive line to eb500-SER
 Send PIN 15'send gps data
 GPS_In PIN 10 'GPS Data in
[color=green]'-------------------------------------------------------
' Variables
'-------------------------------------------------------[/color]
RecCount VAR Byte
nCount VAR Nib
x VAR Nib
GPSData VAR Byte(24) [color=green]'GPS Data from module[/color]
GPS_Baud CON T4800 [color=green]' 4800,8,N,1
[/color]eb500_Baud CON T9600 [color=green]' 9600,8,N,1[/color] 

[color=green]'------------- First Screen ---------------[/color]
DEBUG [color=red]"GPS Tracking: "[/color]
PAUSE 2000
Initialize:
RecCount = 0
[color=green]'-----------------------------------------------------------
' Main program
'-----------------------------------------------------------[/color]
Main:

GOSUB DisplayData [color=green]'LCD Dispaly GPS Data[/color]
PAUSE 1000 [color=green]'About per sample/per 1 sec.[/color]
GOTO Main
'END
[color=green]'-----------------------------------------------------[/color]
[color=green]'************************************************* **********
' Change GPS Data format "xxxx.xxxx,N,xxxxx.xxxx,W"
' to Google Earth Data format "xxxx.xxxx,-xxxxx.xxxx"
'************************************************* **********
'DEBUG GPSData(11),CR
[/color]IF GPSData(11) = "N" THEN
GPSData(0) = " "
ELSE
GPSData(0) = "-"
ENDIF
'DEBUG GPSData(24),CR
IF GPSData(24) = "W" THEN
GPSData(12) = "-"
ELSE
GPSData(12) = " "
ENDIF
GPSData(11)= " "
'DEBUG STR GPSData\23,CR
SEROUT TX, eb500_Baud, [noparse][[/noparse]STR GPSData\23, CR,"!!"] 'Data recording
RETURN
'-----------------------------------------------------
DisplayData:
GOSUB LCD_GPS_Data
DEBUG STR GPSData\11
FOR x = 0 TO 12
GPSData(x) = GPSData(x+12)
NEXT
DEBUG STR GPSData\12
RETURN
'-------------------------------------------------------
LCD_GPS_Time:
GPSData(6) = 0
SERIN GPS_In, GPS_Baud, [noparse][[/noparse]WAIT ("$GPRMC"), SKIP 1, STR GPSData\6]
RETURN
'-------------------------------------------------------
LCD_GPS_data:
GPSData(24) = 0
SERIN GPS_In, GPS_Baud, [noparse][[/noparse]WAIT ("$GPRMC"), SKIP 13, STR GPSData\24]
RETURN
'-------------------------------------------------------
Rec_GPS_data:
GPSData(24) = 0
SERIN GPS_In, GPS_Baud, [noparse][[/noparse]WAIT ("$GPRMC"), SKIP 12, STR GPSData\25]
RETURN
 

PAUSE 1000
DEBUG "Connection established",CR     
'Connect to the remote device
SEROUT TX,eb500_Baud ,[noparse][[/noparse]"con 00:0C:84:00:05:29",CR]
SERIN RX,eb500_Baud ,[noparse][[/noparse]WAIT("ACK",CR)]
'Wait for the connection to be established and switch into data mode.
'When switching into data mode, a 300ms timeout is required to give the
'module enough time to make the change.
WaitForConnection:
DEBUG "Connecting "
  IF IN5 = 0 THEN WaitForConnection
HIGH 6
PAUSE 300

FOR nCount = 1 TO 1
  SERIN RX,eb500_Baud ,[noparse][[/noparse]WAIT("GPS",CR)]
  HIGH 2
  PAUSE 500

NEXT

  DEBUG "Preparing to send SMS message...", CR
  SEROUT TX,eb500_Baud ,[noparse][[/noparse]"AT+CMGF=1",CR]
  PAUSE 500
  SERIN RX,eb500_Baud ,[noparse][[/noparse]WAIT("OK",CR)]
  PAUSE 500
  DEBUG "Sending SMS message...", CR
  SEROUT TX,eb500_Baud ,[noparse][[/noparse]"AT+CMGS=",$22,"XXXXXXXXX",$22,CR]
  PAUSE 500
  SEROUT TX,eb500_Baud ,[noparse][[/noparse]STR GPSdata\23, $1A]

  PAUSE 500

'Switch off GPS
  SERIN RX,GPS_Baud,[noparse][[/noparse]WAIT("TO",CR)]
  DEBUG "Turn off GPS"
  LOW 2
  PAUSE 500
  SEROUT TX,GPS_Baud,[noparse][[/noparse]"Turn off GPS",CR]
  PAUSE 1000


[/code][/size]
··My project is to send gps data to hyperterminal, but there is something wrong in my code.It stops in·debug gps data, and· it does not send·any data to hyperterminal by bluetooth .

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-06-26 18:00
    You may want to put timeouts in your serin statements in case it is getting stuck there. If you connect the device directly to the computer does it work? I would start with a basic setup and expand it only when you get each step working.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.