Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Ads

Discussion Groups

Discussion Groups | BasicX | Problem with serial

Discussion forum for the BasicX family of microcontroller chips.

Problem with serial - gauv...@yahoo.fr - Jan 24 19:43:19 2008

Hello everybody,

I join this forum because I can't get my BX-24 microcontroller to work as I want.
I'm busy making the serial communication between my computer and the microcontoller but I have one little problem. I want the BX-24 to understand what I send him. Let me explain you, I want the basic X to read what I send it and to execute a subroutine according to what I send.
So, to make it simple, I want to send it something like "sensor1" and when it receive that it will send me back the reading of that sensor. All the part for sending the reading of the sensor is working correctly but I don't know how to make an "if" statement with the data I send it.

I would like to make it works like this

if serialinput = "sensor1" then
do something
end if

thank you so much if you can help me
Gauvain



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: Problem with serial - David Sousa Mendes - Jan 25 21:19:50 2008

Hello
I developed a code in which the bx24 communicated with a GSM modem in the same way you describe it..
I'm sending you the pieces of code that you will need:
The commands are single leters because it's much easier to process...

"
If (StatusQueue(InputBuffer)=TRUE)Then
Call GetQueue(InputBuffer, a , 1, 10.0, Failure)
Select Case CInt(a)
Case 63 'Are you there?
call Hello
Case 65 'Current Address Request
call Address
Case 100 'Date Request
call Date_Request
Case 85 'Upload
call Upload
End Select
End If
"

And the settings for th comunications are:
"
Private Const InputBufferSize As Integer = 60 ' Input Buffer for comm
Private Const OutputBufferSize As Integer = 60 ' output Buffer for COM
Private InputBuffer(1 To InputBufferSize) As Byte
Private OutputBuffer(1 To OutputBufferSize) As Byte
Private Success as boolean 'Success in receiving data from COM
Private Failure as boolean 'faillure in receiving data from COM
"

Hop it helps

BR

David M.

----- Original Message -----
From: g...@yahoo.fr
To: b...@yahoogroups.com
Sent: Thursday, January 24, 2008 10:25 PM
Subject: [BasicX] Problem with serial
Hello everybody,

I join this forum because I can't get my BX-24 microcontroller to work as I want.
I'm busy making the serial communication between my computer and the microcontoller but I have one little problem. I want the BX-24 to understand what I send him. Let me explain you, I want the basic X to read what I send it and to execute a subroutine according to what I send.
So, to make it simple, I want to send it something like "sensor1" and when it receive that it will send me back the reading of that sensor. All the part for sending the reading of the sensor is working correctly but I don't know how to make an "if" statement with the data I send it.

I would like to make it works like this

if serialinput = "sensor1" then
do something
end if

thank you so much if you can help me

Gauvain

[Non-text portions of this message have been removed]



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Problem with serial - gauvichounet - Jan 25 21:50:32 2008

--- In b...@yahoogroups.com, "David Sousa Mendes" wrote:

I can do that too, the real problem is that I want to compare what I get from the queue (for
example "SENSOR") to be compared with another string.

thank you anyway

> Hello
> I developed a code in which the bx24 communicated with a GSM modem in the same
way you describe it..
> I'm sending you the pieces of code that you will need:
> The commands are single leters because it's much easier to process...
>
> "
> If (StatusQueue(InputBuffer)=TRUE)Then
> Call GetQueue(InputBuffer, a , 1, 10.0, Failure)
> Select Case CInt(a)
> Case 63 'Are you there?
> call Hello
> Case 65 'Current Address Request
> call Address
> Case 100 'Date Request
> call Date_Request
> Case 85 'Upload
> call Upload
> End Select
> End If
> "
>
> And the settings for th comunications are:
> "
> Private Const InputBufferSize As Integer = 60 ' Input Buffer for comm
> Private Const OutputBufferSize As Integer = 60 ' output Buffer for COM
> Private InputBuffer(1 To InputBufferSize) As Byte
> Private OutputBuffer(1 To OutputBufferSize) As Byte
> Private Success as boolean 'Success in receiving data from COM
> Private Failure as boolean 'faillure in receiving data from COM
> "
>
> Hop it helps
>
> BR
>
> David M.
>
> ----- Original Message -----
> From: gauvichounet@...
> To: b...@yahoogroups.com
> Sent: Thursday, January 24, 2008 10:25 PM
> Subject: [BasicX] Problem with serial
> Hello everybody,
>
> I join this forum because I can't get my BX-24 microcontroller to work as I want.
> I'm busy making the serial communication between my computer and the
microcontoller but I have one little problem. I want the BX-24 to understand what I send
him. Let me explain you, I want the basic X to read what I send it and to execute a
subroutine according to what I send.
> So, to make it simple, I want to send it something like "sensor1" and when it receive
that it will send me back the reading of that sensor. All the part for sending the reading of
the sensor is working correctly but I don't know how to make an "if" statement with the
data I send it.
>
> I would like to make it works like this
>
> if serialinput = "sensor1" then
> do something
> end if
>
> thank you so much if you can help me
>
> Gauvain
>
>
> [Non-text portions of this message have been removed]
>



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Problem with serial - James Parish - Jan 26 14:24:48 2008

I do it all the time, let me know if you want the code, it's pretty
simple and you can compare strings any length up to available
memory. The only thing is it takes all the CHR's from the queue, you
can't sniff "on the fly" for say 5 letters out of 20. You can filter
out certian letters tho..., like spaces & and
--- In b...@yahoogroups.com, "gauvichounet"
wrote:
>
> --- In b...@yahoogroups.com, "David Sousa Mendes"
wrote:
>
> I can do that too, the real problem is that I want to compare what
I get from the queue (for
> example "SENSOR") to be compared with another string.
>
> thank you anyway
>
> > Hello
> > I developed a code in which the bx24 communicated with a GSM
modem in the same
> way you describe it..
> > I'm sending you the pieces of code that you will need:
> > The commands are single leters because it's much easier to
process...
> >
> > "
> > If (StatusQueue(InputBuffer)=TRUE)Then
> > Call GetQueue(InputBuffer, a , 1, 10.0, Failure)
> > Select Case CInt(a)
> > Case 63 'Are you there?
> > call Hello
> > Case 65 'Current Address Request
> > call Address
> > Case 100 'Date Request
> > call Date_Request
> > Case 85 'Upload
> > call Upload
> > End Select
> > End If
> > "
> >
> > And the settings for th comunications are:
> > "
> > Private Const InputBufferSize As Integer = 60 ' Input Buffer
for comm
> > Private Const OutputBufferSize As Integer = 60 ' output Buffer
for COM
> > Private InputBuffer(1 To InputBufferSize) As Byte
> > Private OutputBuffer(1 To OutputBufferSize) As Byte
> > Private Success as boolean 'Success in receiving data from
COM
> > Private Failure as boolean 'faillure in receiving data from
COM
> > "
> >
> > Hop it helps
> >
> > BR
> >
> > David M.
> >
> >
> >
> > ----- Original Message -----
> > From: gauvichounet@
> > To: b...@yahoogroups.com
> > Sent: Thursday, January 24, 2008 10:25 PM
> > Subject: [BasicX] Problem with serial
> >
> >
> > Hello everybody,
> >
> > I join this forum because I can't get my BX-24 microcontroller
to work as I want.
> > I'm busy making the serial communication between my computer
and the
> microcontoller but I have one little problem. I want the BX-24 to
understand what I send
> him. Let me explain you, I want the basic X to read what I send it
and to execute a
> subroutine according to what I send.
> > So, to make it simple, I want to send it something
like "sensor1" and when it receive
> that it will send me back the reading of that sensor. All the part
for sending the reading of
> the sensor is working correctly but I don't know how to make
an "if" statement with the
> data I send it.
> >
> > I would like to make it works like this
> >
> > if serialinput = "sensor1" then
> > do something
> > end if
> >
> > thank you so much if you can help me
> >
> > Gauvain
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
>



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Problem with serial - ericserdahl - Jan 26 20:56:53 2008

I have a similar application. I would appreciate seeing your code.
Would you be so kind as to post in the "files" section?
Thanks, Eric

--- In b...@yahoogroups.com, "James Parish" wrote:
>
> I do it all the time, let me know if you want the code, it's pretty
> simple and you can compare strings any length up to available
> memory. The only thing is it takes all the CHR's from the queue,
you
> can't sniff "on the fly" for say 5 letters out of 20. You can
filter
> out certian letters tho..., like spaces & and
> --- In b...@yahoogroups.com, "gauvichounet"
> wrote:
> >
> > --- In b...@yahoogroups.com, "David Sousa Mendes"
> wrote:
> >
> > I can do that too, the real problem is that I want to compare
what
> I get from the queue (for
> > example "SENSOR") to be compared with another string.
> >
> > thank you anyway
> >
> > > Hello
> > > I developed a code in which the bx24 communicated with a GSM
> modem in the same
> > way you describe it..
> > > I'm sending you the pieces of code that you will need:
> > > The commands are single leters because it's much easier to
> process...
> > >
> > > "
> > > If (StatusQueue(InputBuffer)=TRUE)Then
> > > Call GetQueue(InputBuffer, a , 1, 10.0, Failure)
> > > Select Case CInt(a)
> > > Case 63 'Are you there?
> > > call Hello
> > > Case 65 'Current Address Request
> > > call Address
> > > Case 100 'Date Request
> > > call Date_Request
> > > Case 85 'Upload
> > > call Upload
> > > End Select
> > > End If
> > > "
> > >
> > > And the settings for th comunications are:
> > > "
> > > Private Const InputBufferSize As Integer = 60 ' Input Buffer
> for comm
> > > Private Const OutputBufferSize As Integer = 60 ' output Buffer
> for COM
> > > Private InputBuffer(1 To InputBufferSize) As Byte
> > > Private OutputBuffer(1 To OutputBufferSize) As Byte
> > > Private Success as boolean 'Success in receiving data from
> COM
> > > Private Failure as boolean 'faillure in receiving data
from
> COM
> > > "
> > >
> > > Hop it helps
> > >
> > > BR
> > >
> > > David M.
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: gauvichounet@
> > > To: b...@yahoogroups.com
> > > Sent: Thursday, January 24, 2008 10:25 PM
> > > Subject: [BasicX] Problem with serial
> > >
> > >
> > > Hello everybody,
> > >
> > > I join this forum because I can't get my BX-24
microcontroller
> to work as I want.
> > > I'm busy making the serial communication between my computer
> and the
> > microcontoller but I have one little problem. I want the BX-24 to
> understand what I send
> > him. Let me explain you, I want the basic X to read what I send
it
> and to execute a
> > subroutine according to what I send.
> > > So, to make it simple, I want to send it something
> like "sensor1" and when it receive
> > that it will send me back the reading of that sensor. All the
part
> for sending the reading of
> > the sensor is working correctly but I don't know how to make
> an "if" statement with the
> > data I send it.
> > >
> > > I would like to make it works like this
> > >
> > > if serialinput = "sensor1" then
> > > do something
> > > end if
> > >
> > > thank you so much if you can help me
> > >
> > > Gauvain
> > >
> > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
>



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

RE: Re: Problem with serial - "James R. Parish" - Jan 27 22:59:43 2008

What I do is when I request some text from a serial port I know how many
characters I will be getting. When I get all the characters in the
queue I then go and process them. I step through, skip over ones I
don't want like spaces, LH and CR and then make them all upper case, add
the ASCII value of them together and get a skew number that is 99% of
the time unique. Here is a simple example.

'This SubRoutine takes the reply, strips out any or or
or <##>

'and adds the ASCII value of the chrs together so we can compare

'for a valid reply.

'Returns with a SINGLE in PROMPTIS as a SUM of all remaining CHRs

'

'Variables used:

'X for GP count & loop

'TEMP for Temporary single chr string

'PROMPTIS for a skew number to use for a compare

'

PUBLIC SUB StripPrompt(ByVal PROMPT as STRING)

DIM X as INTEGER

PROMPTIS=0

FOR X = 1 to LEN(PROMPT)

TEMP = MID(PROMPT,X,1)

'DEBUG.PRINT CSTR(X);" CHR = ";CSTR(ASC(TEMP));" ";TEMP

IF ((ASC(TEMP) = 13) OR (ASC(TEMP) = 10) OR (ASC(TEMP) = 32) OR
(ASC(TEMP) = 7)) THEN

GOTO SKIP

ELSE

TEMP = UCASE(TEMP)

END IF

'DEBUG.PRINT " CHR = ";CSTR(ASC(TEMP));" ";TEMP

PROMPTIS = PROMPTIS + CINT(ASC(TEMP))

SKIP:

NEXT

'DEBUG.PRINT"StripPrompt = ";CSTR(PROMPTIS)

CALL LCDCMD(LCDCrsrL2 + 20)
'Move cursor to Line 2 + 20 spaces

CALL PRINTLCD("PROMPTIS = " & CSTR(PROMPTIS) & " ") ;Print
to LCD

END SUB

From: b...@yahoogroups.com [mailto:b...@yahoogroups.com] On Behalf
Of gauvichounet
Sent: Friday, January 25, 2008 1:45 PM
To: b...@yahoogroups.com
Subject: [BasicX] Re: Problem with serial

--- In b...@yahoogroups.com , "David
Sousa Mendes" wrote:

I can do that too, the real problem is that I want to compare what I get
from the queue (for
example "SENSOR") to be compared with another string.

thank you anyway

> Hello
> I developed a code in which the bx24 communicated with a GSM modem in
the same
way you describe it..
> I'm sending you the pieces of code that you will need:
> The commands are single leters because it's much easier to process...
>
> "
> If (StatusQueue(InputBuffer)=TRUE)Then
> Call GetQueue(InputBuffer, a , 1, 10.0, Failure)
> Select Case CInt(a)
> Case 63 'Are you there?
> call Hello
> Case 65 'Current Address Request
> call Address
> Case 100 'Date Request
> call Date_Request
> Case 85 'Upload
> call Upload
> End Select
> End If
> "
>
> And the settings for th comunications are:
> "
> Private Const InputBufferSize As Integer = 60 ' Input Buffer for comm
> Private Const OutputBufferSize As Integer = 60 ' output Buffer for COM
> Private InputBuffer(1 To InputBufferSize) As Byte
> Private OutputBuffer(1 To OutputBufferSize) As Byte
> Private Success as boolean 'Success in receiving data from COM
> Private Failure as boolean 'faillure in receiving data from COM
> "
>
> Hop it helps
>
> BR
>
> David M.
>
> ----- Original Message -----
> From: gauvichounet@...
> To: b...@yahoogroups.com
> Sent: Thursday, January 24, 2008 10:25 PM
> Subject: [BasicX] Problem with serial
> Hello everybody,
>
> I join this forum because I can't get my BX-24 microcontroller to work
as I want.
> I'm busy making the serial communication between my computer and the
microcontoller but I have one little problem. I want the BX-24 to
understand what I send
him. Let me explain you, I want the basic X to read what I send it and
to execute a
subroutine according to what I send.
> So, to make it simple, I want to send it something like "sensor1" and
when it receive
that it will send me back the reading of that sensor. All the part for
sending the reading of
the sensor is working correctly but I don't know how to make an "if"
statement with the
data I send it.
>
> I would like to make it works like this
>
> if serialinput = "sensor1" then
> do something
> end if
>
> thank you so much if you can help me
>
> Gauvain
> [Non-text portions of this message have been removed]
>

[Non-text portions of this message have been removed]



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Problem with serial - gauvichounet - Jan 31 18:37:50 2008

Ok, I've made a program that look like I want it but it doesn't work, here is the code

Dim inputBuffer(1 to 17) as byte
Dim outputBuffer(1 to 17) as byte
Dim inData(1 to 2) as Byte
Dim outData as byte
Dim outputString as string
Dim donnees as String

Sub Main()

call openQueue(inputBuffer, 11)
call openQueue(outputBuffer, 11)

call definecom3(5, 6, bx1000_1000)

call opencom(3, 9600, inputBuffer, outputBuffer)

do
outData = 65 'ascii for A
if getQueueCount(inputBuffer) = 7 then

call getQueue(inputBuffer, donnees, 7)

if donnees = "SENSOR1" then
call putQueue(outputBuffer, outData) 'just sending A if the condition is
met
end if

end if

loop
End Sub
--- In b...@yahoogroups.com, "James R. Parish" wrote:
>
> What I do is when I request some text from a serial port I know how many
> characters I will be getting. When I get all the characters in the
> queue I then go and process them. I step through, skip over ones I
> don't want like spaces, LH and CR and then make them all upper case, add
> the ASCII value of them together and get a skew number that is 99% of
> the time unique. Here is a simple example.
>
>
>
> 'This SubRoutine takes the reply, strips out any or or
> or <##> 'and adds the ASCII value of the chrs together so we can compare
>
> 'for a valid reply.
>
> 'Returns with a SINGLE in PROMPTIS as a SUM of all remaining CHRs
>
> '
>
> 'Variables used:
>
> 'X for GP count & loop
>
> 'TEMP for Temporary single chr string
>
> 'PROMPTIS for a skew number to use for a compare
>
> '
>
>
>
> PUBLIC SUB StripPrompt(ByVal PROMPT as STRING)
>
> DIM X as INTEGER
>
> PROMPTIS=0
>
> FOR X = 1 to LEN(PROMPT)
>
> TEMP = MID(PROMPT,X,1)
>
> 'DEBUG.PRINT CSTR(X);" CHR = ";CSTR(ASC(TEMP));" ";TEMP
>
> IF ((ASC(TEMP) = 13) OR (ASC(TEMP) = 10) OR (ASC(TEMP) = 32) OR
> (ASC(TEMP) = 7)) THEN
>
> GOTO SKIP
>
> ELSE
>
> TEMP = UCASE(TEMP)
>
> END IF
>
> 'DEBUG.PRINT " CHR = ";CSTR(ASC(TEMP));" ";TEMP
>
> PROMPTIS = PROMPTIS + CINT(ASC(TEMP))
>
> SKIP:
>
> NEXT
>
> 'DEBUG.PRINT"StripPrompt = ";CSTR(PROMPTIS)
>
> CALL LCDCMD(LCDCrsrL2 + 20)
> 'Move cursor to Line 2 + 20 spaces
>
> CALL PRINTLCD("PROMPTIS = " & CSTR(PROMPTIS) & " ") ;Print
> to LCD
>
>
>
> END SUB
>
>
>
> From: b...@yahoogroups.com [mailto:b...@yahoogroups.com] On Behalf
> Of gauvichounet
> Sent: Friday, January 25, 2008 1:45 PM
> To: b...@yahoogroups.com
> Subject: [BasicX] Re: Problem with serial
>
>
>
> --- In b...@yahoogroups.com , "David
> Sousa Mendes" wrote:
>
> I can do that too, the real problem is that I want to compare what I get
> from the queue (for
> example "SENSOR") to be compared with another string.
>
> thank you anyway
>
> > Hello
> > I developed a code in which the bx24 communicated with a GSM modem in
> the same
> way you describe it..
> > I'm sending you the pieces of code that you will need:
> > The commands are single leters because it's much easier to process...
> >
> > "
> > If (StatusQueue(InputBuffer)=TRUE)Then
> > Call GetQueue(InputBuffer, a , 1, 10.0, Failure)
> > Select Case CInt(a)
> > Case 63 'Are you there?
> > call Hello
> > Case 65 'Current Address Request
> > call Address
> > Case 100 'Date Request
> > call Date_Request
> > Case 85 'Upload
> > call Upload
> > End Select
> > End If
> > "
> >
> > And the settings for th comunications are:
> > "
> > Private Const InputBufferSize As Integer = 60 ' Input Buffer for comm
> > Private Const OutputBufferSize As Integer = 60 ' output Buffer for COM
> > Private InputBuffer(1 To InputBufferSize) As Byte
> > Private OutputBuffer(1 To OutputBufferSize) As Byte
> > Private Success as boolean 'Success in receiving data from COM
> > Private Failure as boolean 'faillure in receiving data from COM
> > "
> >
> > Hop it helps
> >
> > BR
> >
> > David M.
> >
> >
> >
> > ----- Original Message -----
> > From: gauvichounet@
> > To: b...@yahoogroups.com
> > Sent: Thursday, January 24, 2008 10:25 PM
> > Subject: [BasicX] Problem with serial
> >
> >
> > Hello everybody,
> >
> > I join this forum because I can't get my BX-24 microcontroller to work
> as I want.
> > I'm busy making the serial communication between my computer and the
> microcontoller but I have one little problem. I want the BX-24 to
> understand what I send
> him. Let me explain you, I want the basic X to read what I send it and
> to execute a
> subroutine according to what I send.
> > So, to make it simple, I want to send it something like "sensor1" and
> when it receive
> that it will send me back the reading of that sensor. All the part for
> sending the reading of
> the sensor is working correctly but I don't know how to make an "if"
> statement with the
> data I send it.
> >
> > I would like to make it works like this
> >
> > if serialinput = "sensor1" then
> > do something
> > end if
> >
> > thank you so much if you can help me
> >
> > Gauvain
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
> [Non-text portions of this message have been removed]
>



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )