|
Welcome to the GSM-Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Only registered members may post questions, contact other members or search our database of over 8 million posts. Registration is fast, simple and absolutely free so please - Click to REGISTER! If you have any problems with the registration process or your account login, please contact contact us . |
|
Register | FAQ | Donate | Forum Rules | Root any Device | ★iPhone Unlock★ | ★ Direct Codes ★ | Direct Unlock Source |
GSM Programming & Reverse Engineering Here you can post all Kind of GSM Programming and Reverse Engineering tools and Secrets. |
| LinkBack | Thread Tools | Display Modes |
02-25-2009, 12:09 | #1 (permalink) |
No Life Poster Join Date: Nov 2001 Location: England Age: 41
Posts: 2,821
Member: 7653 Status: Offline Thanks Meter: 823 | Serial Port in VB .NET 2008 Since I discovered the free download of Visual Studio .Net Express 2008 over at the microsoft site, I have had a small play bringing some of my VB 6 code over to the new standards. Attached is a small sample I just wrote to communicate with the Serial Port. The s/w enumerates all available ports automatically and data entred into the upper text box is transmitted to the port on clicking the Tx button. The data sent is terminated by vbCr character (chr(13)) but this can be modified in code. Pauses are used to wait for any recieved data to be filled in the buffer, and the Rx data is then added to the RichTextBox. Again these can be modified or replaced by Do..While loops depending on what device you communicate with. This is not the best way of working with VB.NET, I am reading a lot about threading at the moment. However this very simple code works in my application 100%, and hopefully it can give others a small head start. Good luck! Code: Public Class Form1 Dim comPorts As Array 'Com ports enumerated into here Dim rxBuff As String 'Buffer for receievd data Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'When the form loads 'Enumerate available Com ports and add to ComboBox1 comPorts = IO.Ports.SerialPort.GetPortNames() For i = 0 To UBound(comPorts) ComboBox1.Items.Add(comPorts(i)) Next 'Set ComboBox1 text to first available port ComboBox1.Text = ComboBox1.Items.Item(0) 'Set SerialPort1 portname to first available port SerialPort1.PortName = ComboBox1.Text 'Set remaining port attributes SerialPort1.BaudRate = 19200 SerialPort1.Parity = IO.Ports.Parity.None SerialPort1.StopBits = IO.Ports.StopBits.One SerialPort1.DataBits = 8 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'When Tx button clicked 'Clear buffer rxBuff = "" 'If port is closed, then open it If SerialPort1.IsOpen = False Then SerialPort1.Open() 'Write this data to port SerialPort1.Write(TextBox1.Text & vbCr) 'Pause for 800ms System.Threading.Thread.Sleep(800) 'If the port is open, then close it If SerialPort1.IsOpen = True Then SerialPort1.Close() 'If the buffer is still empty then no data. End sub If rxBuff = "" Then GoTo ends 'Else display the recieved data in the RichTextBox RichTextBox1.Text = rxBuff ends: End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged 'When ComboBox1 selection is changed, we need to update SerialPort1 with the new choise 'But only if the port is closed! If SerialPort1.IsOpen = False Then SerialPort1.PortName = ComboBox1.Text Else : MsgBox("Operation only valid when port is closed.", MsgBoxStyle.Exclamation, "Error") End If End Sub Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived 'This sub gets called automatically when the com port recieves some data 'Pause while all data is read System.Threading.Thread.Sleep(300) 'Move recieved data into the buffer rxBuff = (SerialPort1.ReadExisting) End Sub End Class |
The Following 40 Users Say Thank You to Dave.W For This Useful Post: |
02-25-2009, 12:21 | #2 (permalink) |
No Life Poster Join Date: Nov 2001 Location: England Age: 41
Posts: 2,821
Member: 7653 Status: Offline Thanks Meter: 823 | Uses: This program was intended for communicating with some industrial control application, but is working well with mobile phone over AT command set. Tested with SE K850i connected on USB data link (PC Suite driver installed), and set to phone mode. Send AT command "AT" Send AT service request "AT*" You can find details of AT command set HERE Have fun! Last edited by Dave.W; 02-25-2009 at 14:01. |
The Following 27 Users Say Thank You to Dave.W For This Useful Post: |
03-09-2009, 15:56 | #3 (permalink) |
Junior Member Join Date: Dec 2006 Location: INDIA
Posts: 24
Member: 419417 Status: Offline Thanks Meter: 7 | FBUS command for nokia 1600 Sir would u plz tell how to read nokia firmware detail with usb ....coz i am sending FBUS command to phone command sent sucssesfully but didn't get answer from phone would u plz give some help how to communicate with phone with Visual Basic just read phone type and imei..... Thanks a lot |
The Following User Says Thank You to vikramb1 For This Useful Post: |
03-10-2009, 13:12 | #4 (permalink) |
No Life Poster Join Date: Apr 2005 Age: 39
Posts: 1,162
Member: 138583 Status: Offline Thanks Meter: 120 | Sending SMS using .NET sOURCE Code!!! Hi. As it was not easy for me to find a source code, I will put the page here for make easy for the people: http://www.codeproject.com/KB/IP/Sen...using_Net.aspx if you are using VB8, I recommend u to read this: https://forum.gsmhosting.com/vbb/f83/serial-port-vb-net-2008-a-688748/ Last edited by -luigi-; 03-10-2009 at 13:19. |
The Following 4 Users Say Thank You to -luigi- For This Useful Post: |
03-10-2009, 13:43 | #5 (permalink) |
No Life Poster Join Date: Nov 2001 Location: England Age: 41
Posts: 2,821
Member: 7653 Status: Offline Thanks Meter: 823 | Code in both links is the same thing, only the top link has the added AT command for sensind SMS. Also, you will have problems using that with most manufaturers mobile, as it is working with TEXT mode SMS. Most big manufacturer support only PDU mode. You can find info how to make PDU text messages at: http://www.embedtronics.com/nokia/fbus.html I will merge this with the sticky thread - to make it more accessable for others |
The Following 4 Users Say Thank You to Dave.W For This Useful Post: |
03-10-2009, 13:52 | #6 (permalink) | |
No Life Poster Join Date: Nov 2001 Location: England Age: 41
Posts: 2,821
Member: 7653 Status: Offline Thanks Meter: 823 | Quote:
The source code posted above is for sending AT commands only, you must modify it to send FBUS commands. AT command = string data FBUS = hex data You can find examples how to send FBUS in visual basic by searching the forum, this can be converted to .NET quite easy | |
The Following 8 Users Say Thank You to Dave.W For This Useful Post: |
03-13-2009, 19:10 | #7 (permalink) |
Junior Member Join Date: Dec 2006 Location: INDIA
Posts: 24
Member: 419417 Status: Offline Thanks Meter: 7 | how to read from port in VB6 Sir thanks for reply, actually i am trying to read phones type and imei through FBUS, sending command with MSCOMM in hex values....but didn't get answer from phone how to read data from port and put in string don't get .... data written to com port sucessfully seen in sniffer but unable to catch answer.... |
The Following User Says Thank You to vikramb1 For This Useful Post: |
03-13-2009, 19:12 | #8 (permalink) |
Junior Member Join Date: Dec 2006 Location: INDIA
Posts: 24
Member: 419417 Status: Offline Thanks Meter: 7 | how to read from port in VB6 Sir thanks for reply, actually i am trying to read phones type and imei through FBUS, sending command with MSCOMM in hex values....but didn't get answer from phone how to read data from port and put in string don't get .... data written to com port sucessfully seen in sniffer but unable to catch answer.... phone is nokia 1600 connected to usb. |
The Following User Says Thank You to vikramb1 For This Useful Post: |
03-27-2009, 22:34 | #9 (permalink) |
Junior Member Join Date: Mar 2009
Posts: 13
Member: 993247 Status: Offline Thanks Meter: 5 | hi sir i've downloaded the attachmet and when i tried to open the program it gives me an error and didn't open. i wanna to interface Ericsson T290i with AT COmmand i want when the mobile recieve a message it converts it to binary code that microcontroller understand it to turn on/off devices. i want to know how could i read message from the program i downloaded coz i tried with hyper terminal it gives me error in the reding msg code. so plz i want u to help me sorry if i ask silly question i havn't worked with visual studio before i hope u understand me. |
The Following User Says Thank You to cool_guy4ever15 For This Useful Post: |
03-28-2009, 09:54 | #11 (permalink) |
Junior Member Join Date: Dec 2006 Location: INDIA
Posts: 24
Member: 419417 Status: Offline Thanks Meter: 7 | how to read buffer from comm port Sir when i send command to phone in hex i unable to catch ACK from phone in which event i write code or how i get or read answer from phone plz help |
03-29-2009, 10:25 | #12 (permalink) |
No Life Poster Join Date: Nov 2001 Location: England Age: 41
Posts: 2,821
Member: 7653 Status: Offline Thanks Meter: 823 | Seems you are using VB6, so why are you posting your question in this thread? You should make a new, or better still make a forum search. Any way, take the attachment. Its simple com port source code in VB6, very old source. It is already posted in the forum a few times. |
The Following 6 Users Say Thank You to Dave.W For This Useful Post: |
03-29-2009, 14:39 | #13 (permalink) |
No Life Poster Join Date: Mar 2007 Location: Where you live
Posts: 18,542
Member: 462970 Status: Offline Thanks Meter: 20,352 | Dave.W, can You explain little more about sending comand via usb and recived answer back procedure? I'm coding on delphi, and i found very small info about that on forum... I've seen on this section some code for Delphi by SEMC, but i can't understand how do that... Thanks... and Sorry, if i post in wrong section... |
The Following User Says Thank You to JayDi For This Useful Post: |
03-29-2009, 21:04 | #14 (permalink) |
No Life Poster Join Date: Nov 2001 Location: England Age: 41
Posts: 2,821
Member: 7653 Status: Offline Thanks Meter: 823 | Hi JayDi, All I know is in the first post really. You must install SEMC Data suite then the mobile becomes like a virtual com and you can access with serial port control. I suppose there is other levels of communication also. |
The Following 3 Users Say Thank You to Dave.W For This Useful Post: |
Bookmarks |
| |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
free video tutorial for VB.net | Mind Power | GSM Programming & Reverse Engineering | 6 | 10-07-2011 20:08 |
how to read Cyberflex e-gate cards SN with VB.net | GalaxyMan | GSM Programming & Reverse Engineering | 7 | 04-19-2010 07:45 |
Problem Serial Port in Widcomm 5.1.0.1100 | Nuker5 | Bluetooth-Software | 3 | 07-04-2006 12:45 |
Using serial port in T720i | paulos | Motorola P2k | 0 | 06-11-2004 23:58 |
Flash program for serial port | Byteripper | Nokia Legacy Phones ( DCT-1 ,2 ,3 ,L ) | 5 | 02-02-2001 18:35 |
|