.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


ADVERTISEMENT

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

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

IO.Ports.SerialPort - Writes Fine, Reads Proving?

Jan 24, 2012

I'm having a bit of trouble with the SerialPort class I'm hoping someone might be able to shed some light on. Specifically, writing to the port appears to work without incident. However, reading data is proving problematic. Initially I thought it was my hardware, but testing suggested the fault lied in software. I was able to confirm this with the installation of a loopback device on the port. It tends to be missing bytes, inserting bad bytes, and shifting bytes randomly.

[Code]...

View 1 Replies

SQL Datareader - Returning Result Sets?

Dec 2, 2009

There is a stored proc.. Which was returning to result sets..
Ex:
select * from table1
select * from table2
If I get this data to a Dataset, Definitely I will get 2 data tables with index (0,1)..But what if go though a Datareader? I had checked that just now.. And I got a result of first result set (i.e Table1 in our example)..

View 7 Replies

Create Something That Will Hold The Data And Will Allow The User To Add And Remove Sets Of Data?

Aug 2, 2009

I have a program that simply checks if the account number and pass word match. And if not it allows you to create it. But i have no idea on how to create something that will hold the data and will allow the user to add and remove sets of data.

View 1 Replies

Comport Reads Errors After Number Of Good Reads

Jan 28, 2009

I have a hardware which sends out packets containing 17 bytes to the comport in bursts of 3. the little test VB that I have written receives and displays the bytes in a line of 17 bytes long and works fine until it gets to around 170th packet, then it starts to mix up (looks like shifting the data left) the bytes shift mostly by one digit sometimes by two. then it will continue to give almost a packet correct and a packet shifted for about 50 packets. Then it will correct itself for a long while, but then the speed at which it receives drops. All the packets are sent 3 times, and before things go wrong (within the first 170 packets) the packet counter shows that it receives 3 packet each time but after the problem it goes to 2 packet per burst and then to one.

If i close my VB monitoring program say at packet 165 and immediately open it again, it wont go wrong for another 170 packets, this points the finger at VB. I have check my hardware, there is no problem with that.The program reads port - waits for 17 bytes - once 17 has been received it will go and buffer the packet in an array. In fact they are 2 arrays but printing fro either results in the same problem.I have tried whatever i could think of but to no avail, i am wondering if some kind of house keeping needs to be done to clear something... I am sorry the program is a bit messy but I have been making many changes to find out what the problem is - my code below:[code]

View 11 Replies

Code That Reads An Input File And Store Data In SQL Server Data?

Sep 11, 2009

I am new to VB.net. I want to read and input file and store that data to an SQL Server database. Do you have an sample code that do such?

View 1 Replies

Data From Access, Data Adapters & Data Sets?

Apr 19, 2011

I have a basic application that allows pre-defined users to use the application.The Username & passwords along with some other basic user info is stored in a simple access dbIn my application I want a user to login, Username & PasswordI create a connection string, a data adapter and a dataset, I then need to validate the password the user has entered.Would it be best to query the access db directly, or the dataset?

View 5 Replies

When The App Reads The Data, Encrypts It, And Writes It Back, The New Data Is Appended?

May 9, 2010

A function of my app is to encrypt a file with TripleDES. The problem is that when the app reads the data, encrypts it, and writes it back, the new data is appended. I need it to overwrite the original contents.Here is the code:

Dim
DES As
New
System.Security.Cryptography.TripleDESCryptoServiceProvider[code]............

View 2 Replies

Linking Data Sets?

Mar 26, 2012

I need to link different arrays of data that I am gathering from different Select Cases.For Example:Araray A, B and C from Case 1Array C, D and F from Case 2 Note: Array C is common between two cases.I know in C++ I could have used Pointers and use SQL in Java.

View 1 Replies

Collect Two Sets Of Data From Two Different Databases

Feb 5, 2009

I collect two sets of data from two different databases, This data is now in two collections. I then join/append the one collection to the other and then put it in to a list view.I really would like to order this list view by the first column without the click event.To make this even harder the First column contains Data that is DateTime and i have found that it orders the items by the day number and not the months or years or time.I have found one way but it then cause's me further agony when doing some checks upon the data within the listview later in my code. This answer is to rearrange the format to "yyyy-MM-dd HH:mm:SS" then using the listview.sorting = sortorder.

View 7 Replies

Flexible Data Sets For Functions

Nov 12, 2009

I have only 2 sets of "fixed" numbers used, that I need to be able to toggle between. Particularly, for array sizes/for loops. Is it best to use "Collections" in VB.NET to accomplish this?

View 5 Replies

Regular Expression - Grab Data Between Two Sets Of IDs

Jun 3, 2011

I have a regular expression that I use to grab data between two sets of id's for example:
<CLASSCOD>70</CLASSCOD>
The regular expression I use is:
(?<=<CLASSCOD>)(?:[^<]|<(?!/CLASSCOD))*
Which works in most case but when I have a single value like this
<CLASSCOD>N</CLASSCOD>
It says there are no matches.

The whole data string looks like this :
<STATUS>PRESOL</STATUS>
<DATE>0601</DATE>
<YEAR>11</YEAR>
<AGENCY>Department of the Interior</AGENCY>
<OFFICE>Bureau of Indian Affairs</OFFICE>
[Code] .....

View 2 Replies

Append A Bunch Of Files Into Daily Data Sets?

Feb 16, 2012

I am a newbie at VB.net and would like for you to review my code in order to improve its performance.My objective is to append a bunch of ".csv" files into daily data sets. Within a directory I have about 2500 individual text file (.csv). Each file represents minute intraday stock market data for an individual stock covering 5 days or one week of data. This means that each symbol has 1950 string lines..Here is an example of what a string line looks like: "2011-06-27,10:07,48.15,48.15,48.02,48.02,25421". Not that is relevant but these represent Date, time,Open, High, Low, Close & Volume. Since I have 2500 files within a directory; doing some math, I am processing 2500*1950 = 4,875,000 lines. This process takes me about 16 hrs to run.[code]

View 7 Replies

Record Deletion - Customer And Booking Data Sets On My Form

Mar 15, 2012

I have a customer and booking data sets on my form. customer id is a foreign key in booking table .but when i click delete button. it gives me an error: The DELETE statement conflicted with the REFERENCE constraint "FK_Booking_Customer". The conflict occurred in database "photoshoot", table "dbo.Booking", column 'Cust_id'. The statement has been terminated. Its a one to many relation between customer and booking. one customer can make many bookings each booking will belong to only 1 customer.

View 1 Replies

App That Reads From The Com Port, Filters The Data, Then Writes To The Text Box?

Mar 15, 2009

I am writing an app that reads from the com port, filters the data, then writes to the text box, then immediately starts over. This all takes place in an endless " do while" loop within the "start" button code. I also have a end button too which closes the com port and ends the program. Some other buttons are present also to change the filter settings.Problem is when I click start, data is logged, but none of the other buttons work. Also some of the text boxes are "see through" and dont look like thy have updated with the rest of the form.

View 9 Replies

Make An Application Which Reads Files And Insert Data Into SQL?

Apr 4, 2011

I am using VS2008(VB.NET) and SQL Server2000. I want to make an application which reads files and Insert Data into SQL. If first file has some error. Write into log and Move Next file for Proceed. How can I do that.

View 3 Replies

Datatables - Arrays - Reads Data From Xml File And Displays It In The Datagridview

Oct 2, 2011

I have the following code, which reads data from xml file and displays it in the datagridview. It all works fine:

[Code]...

Instead of showing read data in datagridview, i'd want to read the data from xml file into one dimensional array: X(Impedances) Or is there a way to read value from this datatable into string variable without getting data from datagridview? The point is: i'd want to scan through all "Impedance" values (which are read from xml file) and compare with value y to catch the nearest value to y. How to do that?

View 6 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

Reads & Writes Data From An MSAccess Database Located On A Desktop Computer?

Oct 4, 2010

I should create a program for a Pocket PC that reads & writes data from an MSAccess database located on a desktop computer (pocket PC and desktop one are connected through a Wi-Fi connection).Is that possible?

View 3 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

'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







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