locked
gsm modem RRS feed

  • Question

  • User-230561051 posted

    Hi.

    i have a Siemens TC35i Wireless Terminal. I have build a .net 2.0 application to send and recieve sms from. at first i had a connect / disconnect button and a send button + a textbox for writing commands in. this all worked fine, now i have to do this automatically, eventually from a service, so i cant have any buttons for anything, the application have to know when to connect / disconnect. and here in lies my problem.

    I use the Serialport class for communicating with my modem, and to my belief (correct me if im wrong)  the process of writing commands to it is asyncron, this results in that i dont know when to disconnect. i tried to just write the code like this:

    Connect("COM1") 'connect function

    '
    Set Text mode
    serialPort.WriteLine("AT+CMGF=1" & vbCrLf)

    'Read Message
    serialPort.WriteLine("AT+CMGR=" & strMessageNr & vbCrLf)

    Disconnect() '
    disconnect function

    'then i have a datarecieve function

        Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles serialPort.DataReceived
            Retval += serialPort.ReadExisting
    End Sub
    retval is a property i then use to fetch the data.
    problem is, when i run Disconnect() the process terminates (as is should) 
    but the write process (wich is asyncron) is not done, so it terminates before i get any data.
    i have not been able to find any "im done writing now" function or return value from the write process
    if i had i could always do a pause loop, and ask if its finished.
    can anyone help me get out of the dark on this one, because i obviously dont know enough about these things.
     
    thanks alot,
    Anders Bohlin.
     
    Tuesday, April 25, 2006 3:13 AM

All replies

  • User-403641541 posted
    though it's asynchronous, I'm not sure you want to actually specify a disconnect prior to receiving data ...
    Wednesday, April 26, 2006 12:34 PM