Results 1 to 8 of 8

Thread: ascii setup for hyperterminal using vb.net

  1. #1
    Join Date
    Aug 2008
    Location
    malaysia
    Posts
    31
    Rep Power
    0

    ascii setup for hyperterminal using vb.net

    hi,

    I'm using vb.net 2005, hyperterminal and fargo maestro 100 modem.

    I have tried to use AT command in the hyperterminal to send and receive message.

    Now, i'm using vb.net to open the hyperterminal and write the AT command for me.
    I want to know set the the hyperterminal ascii setup property from vb.net.
    For the ascii sending: i need to tick send line end with line feeds
    For the ascii receiving : i need to tick force incoming data to 7 bit ascii

    Thanks!

  2. #2
    Join Date
    Mar 2008
    Location
    pd
    Posts
    497
    Rep Power
    148
    Why would you want to do that?
    Hyperterminal uses configuration files, doesn't it?
    Unless it exposes an API (maybe it does, but I doubt it), you won't be able to directly control HT's behaviour from VB. If you absolutely had to, you could use the Windows window manager API to bring a HyperTerminal to front, and then the keyboard API to send it Key Events to operate the menus, but it would be an abysmal kludge.
    Why aren't you just using a Serial Communications control (I can't remember the terminology, it's been half a lifetime since I programmed in VB) to control the modem from VB? Then you'd be able to just read and write from the modem as you wished.
    The control is called MSComm, a quick search tells me.
    You may have to turn responses on at the modem at some point, I think many modems default to "silent" operation. From memory:
    ATQ0 = not quiet (responses - such as "OK")
    ATQ1 = quiet (no responses)
    ATE0 = no echo (can't see what you type)
    ATE1 = echo (can see what you type)

  3. #3
    Join Date
    Aug 2008
    Location
    malaysia
    Posts
    31
    Rep Power
    0
    I used something call Imports System.IO.Ports to communicate with the HP.

    I manage to open the port to the HP but can't configure the things that i asked earlier.
    Below is code which i used to open the HP:

    Imports System.IO.Ports

    Public Class Form1
    Dim port As New SerialPort

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Try
    With port
    .BaudRate = 9600
    .DataBits = 8
    .Parity = IO.Ports.Parity.None
    .StopBits = IO.Ports.StopBits.One
    End With

    port.Open()

    MessageBox.Show("Connection Opened Successfully")

    Catch myerror As Exception
    MessageBox.Show("Error Connecting to hyperterminal:" & myerror.Message)
    End Try
    End Sub

    Is it wrong to this way?

  4. #4
    Join Date
    Mar 2008
    Location
    pd
    Posts
    497
    Rep Power
    148
    For the ascii sending: i need to tick send line end with line feeds
    Are you writing a VB app to interface directly with the modem? You'll have complete control over your EOL then. Just send CRLF at the end of your commands, if it's needed by the modem. That's all that the option in hyperterminal does, I expect.

    Your code looks pretty much like the VB I remember. Did it claim to work?

    For the ascii receiving : i need to tick force incoming data to 7 bit ascii
    Not sure about this one - your port settings are for 8-bit data in your VB fragment... are you receiving 7-bit or 8 bit data from your GSM modem?

  5. #5
    Join Date
    Aug 2008
    Location
    malaysia
    Posts
    31
    Rep Power
    0
    This is the code i come out after some reading and searching from internet.

    I'm not sure as well because i think the data should be in 7-bit. however, the default setting for the hyperterminal is need to be databits = 8.

    I have tried out this setting and directly type the AT command in the HP.
    I can send and receive sms successfully.

    Quote Originally Posted by Seanie View Post
    Just send CRLF at the end of your commands, if it's needed by the modem.
    Did you mean i need to do it like this:
    With port

    .BaudRate = 9600
    .DataBits = 8
    .Parity = IO.Ports.Parity.None
    .StopBits = IO.Ports.StopBits.One
    .DtrEnable = True
    .RtsEnable = True
    .NewLine = vbCrLf >>>the CRLF which you mentioned
    End With

  6. #6
    Join Date
    Mar 2008
    Location
    pd
    Posts
    497
    Rep Power
    148
    Something like that. I imagine the SerialPort.NewLine property sets the End Of Line for a WriteLine() function, or whatever is provided by SerialPort, so, once you've set NewLine you should be able to WriteLine("AT"), and not have to specify the CRLF again.

    As for 7 or 8 bit, it probably doesn't matter. The important thing is that the serial port on your PC matches the serial port on the GSM modem.

  7. #7
    Join Date
    Aug 2008
    Location
    malaysia
    Posts
    31
    Rep Power
    0
    No. It can't work as well.

    As i mentioned earlier, i have successful open the port with this code:
    Code:
    Imports System.IO.Ports
    
    Public Class Form1
        Dim port As New SerialPort
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                With port
                    .BaudRate = 9600
                    .DataBits = 8
                    .Parity = IO.Ports.Parity.None
                    .StopBits = IO.Ports.StopBits.One
                    .NewLine = vbCrLf
                End With
                port.Open()
                
                MessageBox.Show("Connection Openned Successfully")
    
            Catch myerror As Exception
                MessageBox.Show("Error Connecting to hyperterminal:" & myerror.Message)
            End Try
        End Sub

    After that, i create another button that if i click on it. The vb.net will write AT command in HP
    Code:
     
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    
            Try
                
                port.WriteLine("AT+CMGF=1" & vbCr)
                System.Threading.Thread.Sleep(200)
                port.WriteLine("AT+CMGS=" & Chr(34) & mynumber & Chr(34) & vbCr)
                System.Threading.Thread.Sleep(200)
                port.WriteLine("test sending SMS!" & vbCrLf & Chr(26))
                System.Threading.Thread.Sleep(200)
    
              
            Catch myerror As Exception
                MessageBox.Show("Error Connecting to hyperterminal:" & myerror.Message)
            End Try
           
        End Sub
    But i didn't receive the message which i send.

  8. #8
    Join Date
    Mar 2008
    Location
    pd
    Posts
    497
    Rep Power
    148
    port.WriteLine("AT+CMGF=1" & vbCr)
    Should you be appending that CR? I think the WriteLine should be appendig your EOL for you. You could always try to see if that was the cause of the problem by opening HyperTerminal and trying to type:
    AT+CMGF=1 followed by Ctrl-M followed by Ctrl-J followed by Ctrl-M , and then do the same for the next command.

    I think what you might be getting is the first line being accepted, then the second line starts with a Ctrl-M, maybe. Are you reading the 'OK's from the modem? A good test that your commands are kosher is to check for the OK.

    Another issue you might run into, if the modem is responding, and you're not reading responses, and you're using some sort of flow control, is that a buffer may fill up and the modem will be 'stuck' until the buffer is emptied (read). I think that's unlikely to be a problem in your case. I program a microcontroller from time to time that has a 1-byte receive buffer, so unread replies can be a problem!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. setup web dummies - please help
    By azlan4220 in forum Website Design
    Replies: 16
    Last Post: 24-04-2009, 11:35 AM
  2. save data from hyperterminal into mysql through vb.net
    By areah in forum Website Programming
    Replies: 5
    Last Post: 23-12-2008, 03:40 PM
  3. nak setup php,mysql
    By zuriani in forum Website Programming
    Replies: 15
    Last Post: 05-12-2007, 10:13 PM
  4. Setup webmail sendiri
    By smartki in forum Website Programming
    Replies: 6
    Last Post: 10-05-2005, 11:30 PM
  5. Network Setup Problem
    By Klausner in forum Mamak Stall
    Replies: 3
    Last Post: 06-11-2004, 09:06 AM

Posting Permissions

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

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39