Double quote in string

Discuss the Firewing language

Double quote in string

Postby AndrewB » Tue Nov 10, 2020 5:53 pm

How do I add double quotes in a string to be sent down Uart?

Ive tried adding a \ before each " but does not work.

Cant find any reference to this on forum or website .
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Double quote in string

Postby David John Barker » Thu Nov 12, 2020 8:33 am

This short program shows you how to do it:

Code: Select all
' main program...
Sub Main()
   while true
      console.write($22, "this is my text", $22) 
      console.write(13,10)
      delayms(1000)
   end while
End Sub

Basically, you are sending the ASCII character " as 0x22 (34 decimal)
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: Double quote in string

Postby AndrewB » Thu Nov 12, 2020 9:30 am

Thanks
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Double quote in string

Postby AndrewB » Thu Nov 12, 2020 1:26 pm

This is the text I'm trying to send

T+CPMS="SM","SM","SM"

How do I implement thisd in the Uart2.write CMD?

Thanks
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Double quote in string

Postby David John Barker » Thu Nov 12, 2020 1:49 pm

All the following code is untested...

Code: Select all
 uart2.write("T+CPMS=",$22,"SM",$22,",",$22,"SM",$22,",",$22,"SM",$22)

should do it.

If that does your head in, you can roll your own code...

Code: Select all
imports uart2
Sub writeCmd(command As String) 
   dim index as byte = 0     
   
   // loop until string terminator found...
   while command(index) <> nothing       
     
      // look for single quote - if found, then
      // emit double quote...
      if command(index) = cchar($27) then
         uart2.write($22)
     
      // else just write the char...
      else   
         uart2.write(command(index))
      end if
      index += 1
   end while
End Sub

sub main()
   writeCmd("T+CPMS='SM','SM','SM'")
end sub
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: Double quote in string

Postby AndrewB » Thu Nov 12, 2020 1:53 pm

Ah I have to add $22 before and after each quote :)
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Double quote in string

Postby AndrewB » Sun Nov 15, 2020 1:08 pm

Im having problems comunicating to this sim modem.
Works Ok if I just send a cmd via console and read bytes back.

If I try to use strings to capture the reply it just locks up.
I know it my programming capabilties :)
Ive tried all sorts of ways to do it but not with any success.
Any help would be appreciated . Thanks

Hers my code below
Code: Select all
' Imports section...

' Declarations...

' import Uart modules...
imports Uart
imports Uart2
Imports Strings


' main program entry point...
Sub Main()
   Uart.SetBaudrate(Uart.Baudrate.Is38400)
   Uart2.SetBaudrate(Uart2.Baudrate.Is4800)
   Uart.ReadTerminator = 13   
   dim command as string 
   dim number1 as string 
   dim b as string(256)
   dim nxtStr as ushort = 0
   dim data as byte = 0
  Uart2.Write("AT",13,10)
 
      'Uart2.Write("ATEO",13,10)   
       
     'Uart2.Write("AT+CVHU=0",13,10)
     
    'Uart2.Write("AT+CPMS=",$22,"SM",$22,",",$22,"SM",$22,",",$22,"SM",$22,13,10)
     
   ' Uart.Write("AT+CPMS=",$22,"SM",$22,",",$22,"SM",$22,",",$22,"SM",$22,13)
   while true 
   nxtStr = 0
   data = 0
      if uart.DataAvailable then
        Uart.Read(command)
        'Uart2.Write("AT+CPMS=",$22,"SM",$22,",",$22,"SM",$22,",",$22,"SM",$22,13,10)
        Uart2.Write(command,13,10)   
      end if 
      delayms(100)             
     if Uart2.DataAvailable then 
      'Console.Write("data here") 
         do
         data = Uart2.Readbyte()
         b(nxtStr) = data
         nxtStr += 1
         loop until  data = 13
        'Uart.WriteByte(Uart2.ReadByte())
        Console.Write("reply is ",b)   
        'uart2.read(number1)
       'Uart.Write(number1,13,10)
     end if
   end while
End Sub
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x