Click here to Skip to main content
16,005,162 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: sending data through the serial port Pin
Joshua Quick17-May-06 14:01
Joshua Quick17-May-06 14:01 
GeneralRe: sending data through the serial port Pin
wtfskh17-May-06 18:51
wtfskh17-May-06 18:51 
GeneralRe: sending data through the serial port Pin
Joshua Quick17-May-06 21:28
Joshua Quick17-May-06 21:28 
GeneralRe: sending data through the serial port Pin
Steve Pullan17-May-06 22:20
Steve Pullan17-May-06 22:20 
GeneralRe: sending data through the serial port Pin
wtfskh18-May-06 2:22
wtfskh18-May-06 2:22 
GeneralRe: sending data through the serial port Pin
wtfskh18-May-06 10:42
wtfskh18-May-06 10:42 
GeneralRe: sending data through the serial port Pin
Steve Pullan18-May-06 14:58
Steve Pullan18-May-06 14:58 
GeneralRe: sending data through the serial port [modified] Pin
wtfskh22-May-06 2:21
wtfskh22-May-06 2:21 
Included is code I am using to try and get the com port to transmit. I was working on this last night. I am looping the output right back into the input at this time just for testing purposes, and yes I am trying to send the hex value I did commit out some of the stuff that you see because I wasn't sure if I needed it and the reason for using the button is we are activating this on a timer..

Imports System
Imports System.IO
Module Module1

End Module
Public Class Form1
Public Shared Function Hex(ByVal Number As Byte) As String

End Function


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GetSerialPortNames()
'dtrenabled = True
Dim baudRate As Integer = 1200
Dim stopbits As System.IO.Ports.StopBits = IO.Ports.StopBits.One
Dim ports As String = "COM1"
Dim databits As Integer = 8
Dim parity As Boolean = False
'Dim com1 As System.IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort(ports, baudRate, parity, databits, stopbits)

'Console.WriteLine(Bite(0) & Bite(1) & Bite(2))
'Junk to stop the console closing
'Console.WriteLine("Press Enter/Return to close")
'Dim PressEnter As String = Console.ReadLine()



End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim stopbits As System.IO.Ports.StopBits = IO.Ports.StopBits.One
Dim Synk As Byte = 255
Dim Servo As Byte = 241
Dim MoveIt As Byte = 100
Dim Bite() As Byte = {Synk, Servo, MoveIt}
' Send commands to a serial port
Using com1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("COM1", 1200, IO.Ports.Parity.None, 8, stopbits)
com1.Write(Bite(0))
txttransmit1.Text = (Bite(0))

com1.Write(Bite(1))

com1.Write(Bite(2))


End Using


End Sub

Sub GetSerialPortNames()
' Show all available COM ports.
For Each sp As String In My.Computer.Ports.SerialPortNames
cmbcomport.Items.Add(sp)
Next

End Sub
Function ReceiveSerialData() As Byte
' Receive bytes from a serial port.
Dim sname As String
Dim returnStr As String
Dim retdata As Byte

sname = cmbcomport.Text
Using com1 As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSerialPort("COM1")
Do
Dim Incoming As Byte = com1.ReadByte()
If Incoming Like Nothing Then
Exit Do
Else
returnStr &= Incoming
End If
Loop
End Using

retdata = ("returnStr")
txtreceive1.Text = (retdata)
Return retdata

Scott

-- modified at 15:39 Monday 22nd May, 2006
Questiondynamic listbox event not firing Pin
gooseman11217-May-06 7:01
gooseman11217-May-06 7:01 
QuestionKeyDown and Timer Tick events cant work together Pin
KaKa'17-May-06 6:18
KaKa'17-May-06 6:18 
AnswerRe: KeyDown and Timer Tick events cant work together Pin
Joshua Quick17-May-06 10:23
Joshua Quick17-May-06 10:23 
QuestionVB Code - Ordering Calaculation Pin
NickiG17-May-06 5:09
NickiG17-May-06 5:09 
AnswerRe: VB Code - Ordering Calaculation Pin
Rizwan Bashir17-May-06 5:38
Rizwan Bashir17-May-06 5:38 
QuestionRemoting - Authentication Failure Pin
dlarkin7717-May-06 4:24
dlarkin7717-May-06 4:24 
AnswerRe: Remoting - Authentication Failure Pin
Rizwan Bashir17-May-06 5:41
Rizwan Bashir17-May-06 5:41 
GeneralRe: Remoting - Authentication Failure Pin
dlarkin7717-May-06 6:03
dlarkin7717-May-06 6:03 
QuestionLookupAccountSid API call Pin
f.duncan17-May-06 3:56
f.duncan17-May-06 3:56 
QuestionHow can I get patterns of viruses? Pin
JUNEYT17-May-06 3:46
JUNEYT17-May-06 3:46 
Questionsizing handles Pin
safalmittal17-May-06 3:28
safalmittal17-May-06 3:28 
AnswerRe: sizing handles Pin
Rizwan Bashir17-May-06 5:47
Rizwan Bashir17-May-06 5:47 
QuestionAttempted to read or write protected memory Pin
dptalt17-May-06 2:54
dptalt17-May-06 2:54 
AnswerRe: Attempted to read or write protected memory Pin
Rizwan Bashir17-May-06 5:56
Rizwan Bashir17-May-06 5:56 
QuestionCould not update datasource using oledbcommandbuilder Pin
hisuman10017-May-06 2:15
hisuman10017-May-06 2:15 
AnswerRe: Could not update datasource using oledbcommandbuilder Pin
adrianamaria17-May-06 16:54
adrianamaria17-May-06 16:54 
Questionget IP addressof remote host(not URL) Pin
QuickDeveloper17-May-06 0:09
QuickDeveloper17-May-06 0:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.