CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2012
    Location
    Prizren
    Posts
    37

    How can I receive data from a PBX machine after I get gonnected to it?

    Hello there I'm encountering an issue recently and been searching more than two months but haven't found a solution for it yet. I have to write a program/application (which I already started in VB.NET 2010) that connects through Panasonic KX-TEM824 PBX machine via RS232 port (cable already connected : COM15/16 depending on USB I connect) and while it's connected to parse(receive) the data from the PBX itself, data that has caller ID, time of call started and ended, duration of the call and etc. I have found some already application on the Internet that does the work but they are free to try after awhile requires to buy or restart the app again. But I assume there's not much to implement on the code side. Please I really need help. I'm posting code below. P.s. it's for study purpose.

    Imports System
    Imports System.ComponentModel
    Imports System.Threading
    Imports System.IO.Ports
    Public Class frmMain
    Dim myPort As Array 'COM Ports detected on the system will be stored here
    Delegate Sub SetTextCallback(ByVal [text] As String) 'Added to prevent threading errors during receiveing of data

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'When our form loads, auto detect all serial ports in the system and populate the cmbPort Combo box.
    myPort = IO.Ports.SerialPort.GetPortNames() 'Get all com ports available
    cmbBaud.Items.Add(9600) 'Populate the cmbBaud Combo box to common baud rates used
    cmbBaud.Items.Add(19200)
    cmbBaud.Items.Add(38400)
    cmbBaud.Items.Add(57600)
    cmbBaud.Items.Add(115200)

    For i = 0 To UBound(myPort)
    cmbPort.Items.Add(myPort(i))
    Next
    cmbPort.Text = cmbPort.Items.Item(0) 'Set cmbPort text to the first COM port detected
    cmbBaud.Text = cmbBaud.Items.Item(0) 'Set cmbBaud text to the first Baud rate on the list

    btnDisconnect.Enabled = False 'Initially Disconnect Button is Disabled

    End Sub

    Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
    SerialPort1.PortName = cmbPort.Text 'Set SerialPort1 to the selected COM port at startup
    SerialPort1.BaudRate = cmbBaud.Text 'Set Baud rate to the selected value on

    'Other Serial Port Property
    SerialPort1.Parity = IO.Ports.Parity.None
    SerialPort1.StopBits = IO.Ports.StopBits.One
    SerialPort1.DataBits = 8 'Open our serial port
    SerialPort1.Open()

    btnConnect.Enabled = False 'Disable Connect button
    btnDisconnect.Enabled = True 'and Enable Disconnect button

    End Sub

    Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
    SerialPort1.Close() 'Close our Serial Port

    btnConnect.Enabled = True
    btnDisconnect.Enabled = False
    End Sub

    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
    SerialPort1.Write(txtTransmit.Text & vbCr) 'The text contained in the txtText will be sent to the serial port as ascii
    'plus the carriage return (Enter Key) the carriage return can be ommitted if the other end does not need it
    End Sub

    Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
    ReceivedText(SerialPort1.ReadExisting()) 'Automatically called every time a data is received at the serialPort
    End Sub
    Private Sub ReceivedText(ByVal [text] As String)
    'compares the ID of the creating Thread to the ID of the calling Thread
    If Me.rtbReceived.InvokeRequired Then
    Dim x As New SetTextCallback(AddressOf ReceivedText)
    Me.Invoke(x, New Object() {(text)})
    Else
    Me.rtbReceived.Text &= [text]
    End If
    End Sub

    Private Sub cmbPort_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPort.SelectedIndexChanged
    If SerialPort1.IsOpen = False Then
    SerialPort1.PortName = cmbPort.Text 'pop a message box to user if he is changing ports
    Else 'without disconnecting first.
    MsgBox("Valid only if port is Closed", vbCritical)
    End If
    End Sub

    Private Sub cmbBaud_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBaud.SelectedIndexChanged
    If SerialPort1.IsOpen = False Then
    SerialPort1.BaudRate = cmbBaud.Text 'pop a message box to user if he is changing baud rate
    Else 'without disconnecting first.
    MsgBox("Valid only if port is Closed", vbCritical)
    End If
    End Sub
    End Class

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,486

    Re: How can I receive data from a PBX machine after I get gonnected to it?

    Well first of all you did not tell us what you are having a problem with and secondly you did not use Code tags so your code is unreadable.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,585

    Re: How can I receive data from a PBX machine after I get gonnected to it?

    Rtfm!
    to programme and administer the pbx by pc (personal computer), you need to install kx-te maintenance
    console onto the pc. To install and start kx-te maintenance console when the pc and the pbx are
    connected, refer to the installation manual ( 3.1.1 installing kx-te maintenance console on a pc). Kxte
    maintenance console starts the programme using the drive where you installed the software
    automatically.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2012 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Feb 2012
    Location
    Prizren
    Posts
    37

    Re: How can I receive data from a PBX machine after I get gonnected to it?

    Yeah sorry about tags for codes didn't work somehow or (I'm new to this forum and don't really know how to use special formatting for my code). The problem stands that I cannot insert any data to my TextBox after I get connected. Don't know what kind of codes should I really use. As I explained it earlier I have a Panasonic KX-TEM824. I've been reading that each of the PBX machines have their own modulation of bytes to characters.

    The whole code there works but doesn't show me resulsts...I get to connect the Panasonic with the app but nothing happens after that no result.

    Thanks for giving time to read my question.

  5. #5
    Join Date
    Feb 2012
    Location
    Prizren
    Posts
    37

    Red face Re: How can I receive data from a PBX machine after I get gonnected to it?

    Ok I started to download the maitenance console app for KX-TEM. I'll refer to you in future if I counterfeit any issue or problem...and I hope it's not only in Russian language developed since I don't understand a thingy. Thnx for the quote. Been very helpful.


    Quote Originally Posted by dglienna View Post
    Rtfm!

  6. #6
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,662

    Re: How can I receive data from a PBX machine after I get gonnected to it?

    Most Comm's with the PABX require's you to poll it for information..

    Send a command to it to start logging the info.
    It will respond OK..
    Send command to retrieve info
    It will respond with data..

    then you also have to ensure you decode the data correctly..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  7. #7
    Join Date
    Feb 2012
    Location
    Prizren
    Posts
    37

    Re: How can I receive data from a PBX machine after I get gonnected to it?

    I already did application which receives the data from the PBX machine whenever it fires the DataReceived event of the serial port control. One thing I for sure don't know is that what do you mean by polling? Because once I've read briefly a thread that there are two ways of receiving data and one of them was by polling.

    That's for sure that usually I don't get any data unless there are some already stored data that had to be transferred through the RS232 port to my app or if those were already logged until there is any call received or made by company employees. If you need the code to see there's another thread made by me in this forum. You can find it out here:

    http://www.codeguru.com/forum/showth...33#post2056433

  8. #8
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,662

    Re: How can I receive data from a PBX machine after I get gonnected to it?

    Quote Originally Posted by Venn View Post
    I already did application which receives the data from the PBX machine whenever it fires the DataReceived event of the serial port control. One thing I for sure don't know is that what do you mean by polling? Because once I've read briefly a thread that there are two ways of receiving data and one of them was by polling.
    Polling the data =
    Quote Originally Posted by GremlinSA View Post
    Send a command to it to start logging the info.
    It will respond OK..
    Send command to retrieve info
    It will respond with data..

    (Repeat command to retrieve info - Over and Over)
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

+ Reply to Thread

Bookmarks

Posting Permissions

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



HTML5 Development Center

Click Here to Expand Forum to Full Width