Results 1 to 5 of 5

Thread: message format

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2009
    Location
    India
    Posts
    94

    message format

    Dear All,

    I am working with rs232 serial port. If my port is recieving the sms then that sms length is very high then it is not showing that message in text format . It is showing like this format "050003200202C4ECF418440EE7412C7B98EDA6A7DD207238EF5AE7C3A075580E62BFCF6510BDED028100" I wnat to dispaly in text mode that message for that what command hould i use pls let me know
    Regards,
    Venkat

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: message format

    If you are asking about displaying multilined text in your project, then try using the TextBox with MultiLine property set to TRUE. (Don't forget to change the ScrollBars property of TextBox, if you want to display scrollbars)....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: message format

    "050003200202C4ECF418440EE7412C7B98EDA6A7DD207238EF5AE7C3A075580E62BFCF6510BDED028100"
    if you post what the text of that should be then someone might figure how to convert
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2009
    Location
    India
    Posts
    94

    Re: message format

    Quote Originally Posted by westconn1 View Post
    if you post what the text of that should be then someone might figure how to convert
    Quote Originally Posted by westconn1 View Post
    if you post what the text of that should be then someone might figure how to convert
    Hi,

    I wrote the code for sending the sms in pdu mode I mentioning bellow
    vb Code:
    1. Option Explicit
    2. Public bOK                     As Boolean
    3. Public bError                  As Boolean
    4. Public Buffer
    5. Public bMessageStore           As Boolean
    6. Public strMessageBuffer        As String
    7. Public bGreaterSign            As Boolean
    8. Public OL                      As Integer
    9. Private Sub Command1_Click()
    10.    Dim sms As String
    11. If MSComm1.PortOpen = False Then
    12.  
    13.    MSComm1.DTREnable = True
    14.    MSComm1.RTSEnable = True
    15.    MSComm1.RThreshold = 1
    16.    MSComm1.InputLen = 1
    17.    MSComm1.Settings = "115200, N, 8, 1"
    18.    MSComm1.PortOpen = True
    19. End If
    20.  
    21.    
    22.    'echo off
    23.    MSComm1.Output = "ATE0" & Chr$(13)
    24.    Do
    25.       DoEvents
    26.    Buffer = Buffer & MSComm1.Input
    27.    Loop Until InStr(Buffer, "OK")
    28.    
    29.      
    30.    MSComm1.Output = "AT+CMGF=0" & Chr$(13)
    31.    Do
    32.       DoEvents
    33.    Buffer = Buffer & MSComm1.Input
    34.    Loop Until InStr(Buffer, "OK")
    35.    Buffer = ""
    36.    
    37. '   sms = MakeSms("004917212345678", "Does it work?")
    38.     sms = MakeSms("9177414078", "Does it work?")
    39.  
    40.    Debug.Print sms
    41.    
    42.    MSComm1.Output = "AT+CMGS=" & Len(sms) / 2 & Chr$(13)
    43.    Do
    44.       DoEvents
    45.    Buffer = Buffer & MSComm1.Input
    46.    Loop Until InStr(Buffer, ">")
    47.    Debug.Print Buffer
    48.  
    49.    MSComm1.Output = sms + Chr$(26)
    50.  
    51.    Do
    52.       DoEvents
    53.    Buffer = Buffer & MSComm1.Input
    54.    Loop Until InStr(Buffer, "OK")
    55.     Debug.Print Buffer
    56.    MSComm1.PortOpen = False
    57.  
    58. End Sub
    59.  
    60.  
    61. Function MakeSms(number As String, txt As String) As String
    62.   MakeSms = "001100"
    63. '  MakeSms = "0011"
    64.   MakeSms = MakeSms + ConvNumber(number)
    65. '  MakeSms = MakeSms + "000064"
    66.   MakeSms = MakeSms + "0000AA"
    67.  
    68. '   MakeSms = MakeSms + "0000"
    69.   MakeSms = MakeSms + ConvTxt(txt)
    70. End Function
    71.  
    72.  
    73. Function ConvNumber(num As String) As String
    74.  
    75.   Dim i As Integer
    76.   Dim numType As String
    77.  
    78.   'default local number
    79. '  numType = "81"
    80.    numType = "91"
    81.  
    82.   'but if international number then .....
    83. '  If Left$(num, 3) = "+00" And Len(num) > 3 Then num = Mid$(num, 4): numType = "91"
    84. '  If Left$(num, 2) = "00" And Len(num) > 2 Then num = Mid$(num, 3): numType = "91"
    85. '  If Left$(num, 1) = "+" And Len(num) > 1 Then num = Mid$(num, 2): numType = "91"
    86.  
    87.  
    88.   ConvNumber = Right$("00" & Hex(Len(num)), 2)
    89.  
    90.   ConvNumber = ConvNumber + numType
    91.  
    92.   For i = 1 To Len(num) Step 2
    93.     ConvNumber = ConvNumber + Mid$(num + "F", i + 1, 1) + Mid$(num + "F", i, 1)
    94.   Next i
    95.  
    96. End Function
    97.  
    98.  
    99. Function ConvTxt(txt As String) As String
    100.  
    101.   Dim i As Integer
    102.   Dim datArr1(1 To 256) As Byte
    103.  
    104.   Dim l As Integer
    105.   Dim touw As String
    106.  
    107.  
    108.   'no more than 160 chars
    109.   If Len(txt) > 160 Then txt = Left$(txt, 160)
    110.  
    111.   l = Len(txt)
    112.  
    113.   ConvTxt = Right$("00" & Hex(Len(txt)), 2)
    114.   For i = 1 To l
    115.     datArr1(i) = Asc(Mid$(txt, i, 1))
    116.   Next i
    117.  
    118.  
    119.   'make a bit stream of septets
    120.   touw = ""
    121.   For i = 1 To l
    122.     touw = ToBin7(datArr1(i)) + touw
    123.   Next i
    124.  
    125.  
    126.   'and convert it to octets
    127.   While Len(touw) > 8
    128.     ConvTxt = ConvTxt + Bin2Hex(Right$(touw, 8))
    129.     touw = Mid$(touw, 1, Len(touw) - 8)
    130.   Wend
    131.   OL = Len(ConvTxt)
    132. '  OL = Hex$(OL)
    133.   ConvTxt = Bin2Hex(OL) + ConvTxt
    134.   ConvTxt = ConvTxt + Bin2Hex(touw) ' original code
    135. '   ConvTxt = OL + ConvTxt + Bin2Hex(touw) ' added newly
    136.  
    137.   Debug.Print ConvTxt
    138. End Function
    139.  
    140.  
    141. Function ToBin7(ByVal num As Byte) As String
    142.   'convert to padded 7 place binary number
    143.   While num > 0
    144.     ToBin7 = Trim(num Mod 2) + ToBin7
    145.     num = num \ 2
    146.   Wend
    147.    
    148.   ToBin7 = Right$("0000000" + ToBin7, 7)
    149. End Function
    150.  
    151. Function Bin2Hex(ByVal touw As String) As String
    152.   'convert binary to a padded 2 place hex number
    153.   Dim x As Integer
    154.   Dim num As Long
    155.  
    156.   For x = 1 To Len(touw)
    157.     If Mid$(touw, x, 1) = "1" Then
    158.       num = num + 2 ^ (Len(touw) - x)
    159.     End If
    160.   Next x
    161.  
    162.   Bin2Hex = Right$("00" + Hex(num), 2)
    163. End Function
    164. Public Sub Wait()
    165. Dim start
    166.  
    167.    start = Timer
    168.    Do While Timer < start + 8
    169.       DoEvents
    170.       If bOK Then
    171.         Exit Sub
    172.       End If
    173.       If bError Then
    174.         Exit Sub
    175.       End If
    176.    Loop
    177. End Sub
    178.  
    179.  
    180. Private Sub Form_Unload(Cancel As Integer)
    181. End
    182. End Sub
    183.  
    184. Private Sub MSComm1_OnComm()
    185. Static stEvent              As String
    186.  Dim stComChar               As String * 1
    187.         Buffer = ""
    188.                    
    189.  Select Case MSComm1.CommEvent
    190.        
    191.    Case comEvReceive
    192.             Do
    193.  
    194.     On Error GoTo handler
    195.  
    196.                 stComChar = MSComm1.Input
    197.                 Buffer = Buffer + stComChar
    198.                  
    199.                 If bMessageStore Then
    200.                 strMessageBuffer = strMessageBuffer & stComChar
    201.                 End If
    202.                 Select Case stComChar
    203.                     Case ">"
    204.                          bGreaterSign = True
    205.  
    206.                     Case vbLf
    207.  
    208.                     Case vbCr
    209.                         If Len(stEvent) > 0 Then
    210.                           ProcessEvent stEvent
    211.                           stEvent = ""
    212.                         End If
    213.                     Case Else
    214.                         stEvent = stEvent + stComChar
    215.                 End Select
    216.  
    217.             Loop While MSComm1.InBufferCount
    218.    
    219.     Case 2
    220.     MsgBox "Modem Unplugged", vbInformation
    221.     End Select
    222.  
    223. handler:
    224. End Sub
    225.  
    226. Private Sub ProcessEvent(stEvent As String)
    227.   Dim stNumber As String
    228.          If Mid$(stEvent, 1, 5) = "+CMTI" Then
    229. '           frmSendSingleMessage.Enabled = False
    230.            Timer1.Enabled = False
    231.            strMessageBuffer = ""
    232. '           While frmSend.SendingMessage = "yes"
    233. '             DoEvents
    234. '           Wend
    235.               stEvent = ""
    236. '              Command3_Click
    237. '              LoadInbox
    238. '              bpp_list.Refresh
    239.               bOK = False
    240.               bError = False
    241.               MSComm1.Output = "AT+CMGD=1,3" & vbCrLf
    242.             While Not bOK Or bError
    243.                  DoEvents
    244.                  Wait
    245.             Wend
    246. '            Timer1.Enabled = True
    247.            
    248.            If bError Then
    249.               MsgBox "Unable to delete"
    250.            End If
    251.            Exit Sub
    252.          End If
    253.        
    254.           Select Case stEvent
    255.            Case "OK"
    256.              bOK = True
    257.            Case "ERROR"
    258.              bError = True
    259.            Case "RING"
    260.            MsgBox "Incoming Call Alert", vbInformation
    261. '             If bRing = False Then
    262. '               bRing = True
    263. '             End If
    264. '             iRingTime = Timer
    265.            Case Else
    266.              Select Case Left(stEvent, 4)
    267.                Case "TIME"
    268.                Case "DATE"
    269.                Case "NMBR"
    270.                Case "NAME"
    271.              End Select
    272.              
    273.         End Select
    274. End Sub
    Then I got the information in pdu like this "0011000A9119771404870000AA000DC477790E4AD341F7B77CFD03" but it is not going to the distination number. Where is the mistake Please let me know as early as possible it is urgent for me.
    Regards,
    Venky
    Last edited by venky; Feb 22nd, 2010 at 06:48 AM.

  5. #5
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: message format

    Please edit one of your posts to add [highlight=vb] [/highlight] tags around your code, and edit the duplicate post down to one line. Something like: "Duplicate post deleted."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width