SerialPort.DataReceived Not Returning Data?

Dec 29, 2010

Every 5 to 10 seconds I receive 5-12 bytes of data (confirmed w/Hyperterminal). I can open the com port(btn1), read bytes(btn3) until bytes to read = 0, but then i'm stuck; the data received event doesn't seem to respond. If I close the serial port(btn2), re-open i can read more data until bytes to read = 0 then stuck again. I tried several suggestions for threads and delegate and invoke but none worked. (WIndows XP, VB 2008)

[Code]...

View 19 Replies


ADVERTISEMENT

SerialPort DataReceived Event On EOF?

Jul 21, 2009

Im using VB express 2008 (compiled with .NET 3.5) to write a program that communicates with a USB device. The USB device is a communication class device and thus will emulate the usual rs232 serial port once attached to the PC. The USB device sends a fixed number of bytes and i have set the threshold received byte property to this value. I have run the program and it seems to read the USB device "correctly" but when i debug the code, i realise that the datareceived event of the serial port gets fired on the eventtype = EOF. I am using the Read function to read the bytes from the serial port and the Newline property is set to "" (but i thought that this is irrelevant if im not using ReadLine). When the datareceived event fires with EOF, the Read function blocks until one byte arrives, reads it and calls the function that processes the data. I went through the forum and realised that the EOF eventtype is no longer supported, is this true? I dont think that getting this eventtype is logical anyways in my case.

View 5 Replies

SerialPort DataReceived Buffer Construction?

Jun 15, 2011

I've managed to make an application at home using a serialport emulator and connector that will read text from a file on my desktop send it to com1 and then my connector program will merge com1 with com2. In short my program works at home but when I connect it to my device it appears the data in DataReceived is a fraction of what my simulator setup at home is producing, which apparently is completely normal according to all these threads I've read here.

[Code]...

View 4 Replies

Serialport DataReceived Event Never Fires

Apr 2, 2009

When I write a byte array to a device using this code, the DataReceived Event never fires.....

[Code]...

AND if the sleep is <40, the event doesn't fire. Is this necessary or am I overlooking something?

View 11 Replies

Serialport Datareceived Crashes Closing Application?

Jul 8, 2011

I have an application with serial port datareceived event. My instrument sends me aprox.00bytes every 1 second. Which I then process and update few textboxes on the main formRecently my application started crashing if I press close button.I am guessing form_closing closes serialport at the same time datareceived event triggers in which the sp1.bytestoread causes the crash.1. I added synclock in datareceived and in form_closing.Within synclock in form_closing I removed datareceived handler.

View 8 Replies

VS 2010 Can't Enable A Timer From A SerialPort.DataReceived Event

Dec 16, 2010

So I just spent the last 4 hours trying to find out what was wrong with my code, just to find out that there's a bug in this version or I just don't have enough knowledge of VB2010 (I'm coming from VB6, this is my first program on 2010)I removed the rest of the code just to point out the problem, here it simply tries to enable the Timer1 when you receive data in the SerialPort1

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
If Me.Timer1.Enabled = False Then

[code]....

After this I found that the code inside the Timer1 didn't run when the 100miliseconds passed, so I added a msgbox to see debug.

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
If Me.Timer1.Enabled = False Then

[code]....

View 16 Replies

.net - SerialPort Reads Are Returning Fragmented Sets Of Data?

Oct 17, 2011

I have a USB device which creates a Virtual Serial Port on Windows. I am using VB.Net to write and read from the port. My device responds with specific sized set of bytes, but I am finding that SerialPort.Read(byte-array,offset,number-bytes) does not return the full number-bytes but it also does not timeout or generate an exception. Repeated calls return additional fragments (up to 3 calls required). Python code using pySerial does not have the same problem.So, what am I doing wrong here? Am I expecting too much?

Some scenarios are:I write a command to the port and expect to get 4 bytes in response. I get 1 byte first and then 3 bytes on the subsequent call.I write a command and expect 21120 bytes in response. I get 1, 12671 and then 8448 bytes in 3 calls to read from the port.

Here are some excerpts from my code:

Private Sub SetupVirtualSerialPort()
Dim portName As String = "COM" + (m_DeviceContext * -1).ToString
Const baud As Int32 = 9600 '7680000
Const parity As Parity = parity.None

[code]....

View 2 Replies

Reading Data Using SerialPort Object?

Mar 7, 2012

I develop a simple application usiing VB.NET, VisualStudio 2008, that read input from a serial port

(from another device). I use the class SerialPort.

Using HyperTerminal I can see the input , it's fine. looks like :

S0P,A,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0 S0P,A,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

[Code]...

View 5 Replies

Serialport To Receive Data From Instrument Every Second?

Jul 18, 2009

I use the vb .net serialport to receive data from my instrument every second

View 11 Replies

VS 2008 IO.Serialport Does Not Receive Any Data

Apr 6, 2009

I want to use IO.ports.serialport to receive ASCII data from an instrument (A Luxmeter for those interested). So far, i've been unable to read any single byte from the instrument using the IO.ports.serialport.A terminal window shows the datastream just fine, and I've used MScommlib to read the data without problems. I just had other problems with the latter, so I thought I'd give this IO.ports.serialport a try.The code runs fine, no errors. It just doesn't receive anything.Bytestoread stays 0 forever.I distilled the code to it's bare essence. What am I missing? Is it something obvious, or did I completely misunderstand the whole concept? (Which is not unlikely..)I did check the obvious, of course: settings, baudrate, cable is connected, instrument is sending, etc.[code]

View 6 Replies

Communications :: Serialport Data Received Addhandler

Apr 24, 2010

I am writing a small application to see what data I am sending and receiving to my COM port (for a small hardware project based on url..).The problem I want to activate a "Serialread" or "SerialWrite" procedure as soon as data is waiting in the receive or send buffer.I have some basic skills so before I start digging in I would like to get some advice. Can I use a addhandler (I have read something about this on the internet but have to clue how to use it) or something else? Is there a way to check if data is in the buffer ready to be read or write??

View 2 Replies

Save Data And Send To Serialport Periodically?

Oct 14, 2009

I have a program where I need to periodically save the data to a database (if the computer suddenly shutdown) and also send the same data to a serialport.Alla data that is going to be sent and saved resides in two classes.his needs to be done every 1/10s.What's the best way to manage this?

View 2 Replies

Make A Simple Class That Reads Data From A SerialPort

Aug 17, 2009

I'm trying to make a simple Class that reads data from a SerialPort.The Device returns a number of lines of Strings.[code]However running this code in a Form with one TextBox Control (txtLog) Allways results in the "The operation has timed-out." Exception.[code]

View 3 Replies

'System.StackOverflowException' When Writing Data To SerialPort At Higher Baudrates?

Nov 24, 2010

I am writing a serial application using VB .net Framework V4 , where I use a background worker to Read a file and send it to a serial port using SerialPort1.writeLine method. The BackgroundWorker1.ProgressChanged Event handler sub Updates the Line Number to a TextLabel and adds each line sent to a RichTextBox using RichTextBox1.AppendText() method on main form (Form1).

The problem arises at 115200 Bauds (and higher),may be because now the text is updated real fast on the form an unhandled Exception in BackgroundWorker1.ProgressChanged Event handler sub occurs. Otherwise at lower baudrates ex: 9600,19200 etc. Application Runs Perfectly Fine.

[Code]...

View 6 Replies

Forms :: Serialport Communication - Receive Data To Pc From External Hardware

Sep 5, 2009

i want to receive data to my pc from external hardware but i don't know how to do it since i am new to vb.net. the code in vb.net to receive data using serial port rs232.

View 1 Replies

Receive Data From Serialport & Send It To Anthor Pc Running My Program?

Sep 3, 2010

how to recive data from serialport & send it to anthor pc running my program & resend to the same serialport on the other pc?

View 4 Replies

Receiving Invalid Data From Serial Port Using SerialPort.ReadExisting

Jan 16, 2010

Recently we have connected one bluetooth device which receive data from our serial device. The bluetooth device further transmite this data to a Windows Mobile which is bluetooth enable. Baud rate of whole system is 19200 with 7 data bit and 1 stop bit.When we send command to serial device through bluetooth device it is accepting the command and respond accordingly. but some of data byte of string is desplay as question mark (?).But in case we connect the serial device directly to PC, the string received is correct.[code]Response given by Serial Port is "?09?D03?A D?

View 1 Replies

Receiving Invalid Data From Serial Port Using SerialPort.ReadExisting()

Jan 16, 2010

Recently we have connected one bluetooth device which receive data from our serial device. The bluetooth device further transmite this data to a Windows Mobile which is bluetooth enable. Baud rate of whole system is 19200 with 7 data bit and 1 stop bit.When we send command to serial device through bluetooth device it is accepting the command and respond accordingly. but some of data byte of string is desplay as question mark (?).[code]...

View 4 Replies

VS 2008 Select From Excel Returning Null Data Instead Of Real Data?

Dec 22, 2010

I typed this question once already, hit preview, and somehow never got the preview and lost what I typed. It has been that kind of a day.So here is my quick overview then I am going shopping. I am using OLE DB to select from an excel spreadsheet. It has over 15000 rows and 33 columns. Sometimes even when a cell is not null, it is returning a null value. If I just do a "select * where [termination date] is not null", for example, it will return no rows even though I can see with my own eyes that sometimes termination date is not null.

View 9 Replies

SerialPort Escape String - Retrieving Data From A Device Connected To A Virtual Com-port

Aug 13, 2010

I am writing a small app that is retrieving data from a device connected to a virtual com-port. I connect without problems to the device using the settings 9600-8-N-1.

I need to send the command <esc>MS , the device then sends back the data to a computer. I have tried this using Hyperterminal with success. I also did this with Excel and VBA. I used the MSComm32 Active X control:

MSComm1.Output = Chr$(27) + "M" + "S" + Chr$(13)

Msgbox(MSComm1.Input)

This made the data from the device pop up in a messagebox. I am writing a winforms app in vb.net, using VS2005. I have a form, on which I have a Placed a SerialPort control, named sp. My sample code is as follows:

Private Sub Form1_Load(ByVal
sender As System.Object,
ByVal e

[CODE]...

This returns the error message "Error: expecting a command". I have done som tests in HyperTerminal, and have concluded with:

-If I dont send <esc>, I get error "Expecting a command"

-If I send wrong command (ie MD instead of MS) i get error "Bad command"

Based on this, I suspect that I don't pass the escape character correctly to my device. So I wonder how to do this?

View 5 Replies

SerialPort1.DataReceived Does Not Fire

Sep 10, 2009

I was perhaps too quick to think that VB's built-in event would be be easy to use. As you can see from my previous post I am building a program which sends and receives a few bytes from serial bus. The bus is actually a usb serial adapter, there are no real serial buses in my machine.Anyway that SerialPort1.DataReceived does not fire. It is from visual studio/vb ide so syntax should work? Here is my start up code. There are many comments, because I tried various combinations.

If Not _serialPort.IsOpen Then
If Not arvo = "" Then
_serialPort.DtrEnable = False
_serialPort.Parity = Parity.None

[code]....

View 13 Replies

DataReceived Event And Delegates Reference?

Dec 3, 2009

I'm looking for a reference that can explain the concept and use of the DataReceived event and Delegates subject.The reference has to be pretty simple as I'm an "old dog attempting to learn a new trick". I'm not ignorant of things programming, but am ignorant of things dealing with serial communication in VB2005.I already have a couple of O'Rielly books ("VB2005 Cookbook", "VB2005 Desktop Reference") and I have a book that deals with serial communication from a Jan Axle-something. Neither O'Rielly books have any info, and the Axle-someting book's remotely related examples are too confusing for this slow learner.

View 6 Replies

Serial Port DataReceived Event Not Firing?

Jun 29, 2011

I am trying to get a fairly simple Serial Port program working. So simple in fact I have been bashing my head over it for quite a while.

I have a piece of equipment connected over a null modem cable. When turned on, it just starts spitting data out RS232 and I need to capture it. Hyperterminal does see the data so the USB-serial converter is working.

When I run the code snippet included, the port opens fine, but the DataReceived event never fires.

Imports System.IO
Public Class Form1
Dim WithEvents serialPort As New IO.Ports.SerialPort

[Code]....

View 14 Replies

DB/Reporting :: Returning Data In A Database?

Mar 4, 2010

I would like to return the data in a database query as an array, but the problem is, Im having trouble working out how to do it, here is how I would like the data to be returned:

array (
---> 1
---> ---> 1
---> ---> ---> fieldname

[code]....

I could create a multi dimentional array, but the results could range from 2 rows, to 2000 rows, I looked into redim, but you can only redim the last dimention, I would need to the first and second, but not the last.

View 2 Replies

Module Returning Data Like A Function?

Jul 12, 2010

How could I call a module or something else to return data to me after its ran. I don't want to make my form1 code all messy.

Public Function Test() As String
Return "Tes34t"
End Function

[code]....

View 2 Replies

SQL Data Query That Is Not Returning Any Records

Oct 28, 2010

I am trying to debug my code, which involves a simple webservice that passes parameters to a data class, which calls a stored proc, and returns one row of record. I am not getting any error messages, but I am not getting any records back either.[code]

View 1 Replies

Read Data From A Text File With SERIALPORT While Using "StringReader.ReadLine"?

Jun 30, 2011

read data from a text file with SERIALPORT while using "StringReader.ReadLine"?

View 8 Replies

C# - MVC: Returning Multiple Rows Of Data To Controller?

Apr 23, 2012

I have a table with several rows of data that I need to return to the controller. In my view, I initially load the table by selection of a time period and clicking a button. The table loads all my relevant records but one of my table cells contains a dropdown list. So I should be able make a selection in the dropdown click "update" and my controller saves the changes.

So everything works until I try and save. The model that is sent to the controller is completely null. The list property I have tied to the table cells returns to the controller null.

[Code]...

NOTE: This is written in VB.NET but C# help is welcome. I am familiar with both languages in MVC.

View 3 Replies

Constructor Returning Data To The Calling Form?

Jun 7, 2010

I have a MDI app that I am creating. It, of course, will have multiple MDI child forms. In each child form, I have an options button so that each child form can have it's own set of options. When I click the options button it opens an Options form. This options form is not an MDIChild.

I have a class that contains the child forms options. I pass this class to the options form using a constructor. This is how I call the options form:

Dim dlgPatternOptions As dlgOptions = New dlgOptions(thisPatternOptions)
thisPatternOptions is the class that I am passing to the Options Form.

This works fine and the options form does populate the options correctly. The Options form constructor is this:

Public Sub New(ByRef thePatternOptions As CanvasOptions)
Me.InitializeComponent()
Me.txtCanvasWidth.Text = thePatternOptions.CanvasWidth.ToString
Me.txtCanvasHeight.Text = thePatternOptions.CanvasWidth.ToString
End Sub

I change the options in the options form. How can I get those changes back to the calling form? Do I need to somehow pass a handle of the calling form to the constructor to get the changed values back to the calling form? Is there some way to pass a handle to the options form so that changes made to options will be pushed back to the calling form?

View 2 Replies

Entity Framework Returning Different Data Then DB Query?

Jan 4, 2011

I have a view on some data in my database it returns the data as I would expect, for example

Call Date To From Phone Number
20/1/2010 00:00 23:59 08923233223
20/1/2010 00:00 23:59 08923233245

However when I have added this to my Entity Model and query it I get duplicate(and unexpected) data appearing

Call Date To From Phone Number
20/1/2010 00:00 23:59 08923233223
20/1/2010 00:00 23:59 08923233223

I am simply binding a Entity Data Source to this Entity but I am left scratching my head as to why the data is being returned differently

EDIT: Interestingly this can't be the result of some strange under the hood join as the row counts match as expected. I have also put together a query myself to test with the same odd results.From o In App.Entities.v_PersonalRules Where o.companyid = CompanyID Select o. I am using Visual Studio 2010, .NET 4

EDIT: The front end code is fairly simple

<asp:EntityDataSource ID="EDS_Personal" runat="server" ConnectionString="name=Entities_NEW"
DefaultContainerName="Entities_NEW" EnableDelete="True" EnableInsert="False"
EnableUpdate="True" EntitySetName="v_PersonalRules" EntityTypeFilter="v_PersonalRules" >[code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved