Communications :: Port.BytesToRead Unexpected Results?
Sep 4, 2007
I am writing an app in VB2005 that makes a call to my cars ECU. It sends ok but during the DataReceived event I am getting an unusual result.I am trying to find out how many bytes are in the buffer so I can set up an array to write the data to so I have used the following.
intBTR = _Port.BytesToRead
_Port.Read(bytIncoming, 0, intBTR -1)
[code]......
View 3 Replies
ADVERTISEMENT
Mar 10, 2011
Just when I was thinking that I had Linq To Xml sussed I'm faced with yet another error! I think if I was to understand the linq search process in general better I might have more success, so any good links regarding that are also welcome. To my problem however; using the code below:
[Code]...
View 1 Replies
Feb 20, 2009
Consider the following snippet:
Dim Arext() = {"*.ttf","*.ttc"}
For Each foundFile In FileSystem.GetFiles(srcdir, SearchOption.SearchTopLevelOnly, arExt)
[code]....
The unexpected result is that not all the files specified in arext() are returned by this code. Running the same code twice on the same subset of files does NOT produce consistent results.I'm seeing, probably, 90% of the files with the other 10% not being included?
View 1 Replies
Oct 20, 2011
I am trying to get my 4 port USB relay board to work in VB.net using the COM PORT. I found some code from a poster who has the 16 port USB relay version. When trying his code i can only get it to turn on relays 1-3 all at the same time. The product can be found here: USB 4 port relay
"01+//" - Relay 1 is switched ON
"01-//" - Relay 1 is switched OFF
"02+//" - Relay 2 is switched ON
"02-//" - Relay 2 is switched OFF
[code].....
So i am confused as to how to separate each relay out with that code above and just be able to turn on any number 1-4 relay on or off independently from each other!
View 1 Replies
Oct 15, 2008
Im having problem with the Serial Port. When i run my program, "Access to the port 'COM1' is denied". What does that mean? Im not sure whats happening because theres no error in my code. Someone suggest me to use 'COM2'. Which is also the same result. I have a microcontroller, programmed and run it. And i need to capture the data onto my vb, which is on a multiline textbox. How to i do that?Just to double check my code?
[code]...
View 1 Replies
Oct 20, 2009
x = 4.2 - 0.1
vb.net gives 4.1000000000000005
python gives 4.1000000000000005
Excel gives 4.1
Google calc gives 4.1
What is the reason this happens?
View 4 Replies
Mar 8, 2010
For many years, I have sent data between 2 computers using serial ports."Here is the data", "Thank you for that data!" type stuff.Where do I get more information for doing the same thing with 2 computers that are networked together? Assume a local ethernet connection.I have experimented with serial-ethernet modems and that works well but I don't want any more hardware.Is there a good thread here I should read?I want 2 VB programs running and I want to exchange data periodically.
View 2 Replies
Feb 26, 2009
i am working with a printer connected to port1 this is not like regular printer.it is like a current bill generator printer.when we type data directly it has to print on paper
Mscomm1.Output = txtMessage.Text & vbCr
the code is working the problem is iam not able to set the fonts?
View 1 Replies
Jun 27, 2012
Edit: Here is a much more simpler example of this issue (i've deleted my original question):
Dim numbers1 As New List(Of Int32)({1, 2, 3})
Dim numbers2 As New List(Of Int32)({3, 4, 5})
For Each n1 In numbers1
' no warning '
Dim contains = numbers2.Contains(n1)
Next
[Code]...
The local variable number1 is redundant and makes the code less readable as @Meta-Knight already has emphasized. Note: All three ways are safe and give the correct result.
View 2 Replies
Mar 1, 2012
Possible Duplicate:Why is it bad to use a iteration variable in a lambda expression.why do I get: "iteration variable in a lambda expression may have unexpected results"? Suppose I have the following code:
[Code]...
View 2 Replies
Sep 21, 2011
I am trying to listen to the COM3 port and display the output in the TextBox. If I understood correctly I will have to implement this by using eventhandlers, delegates. I tried following these articles:
[URL]
And this is the code I came up with... Unfortunately it doesn't display anything. App just starts display "True" and no data is being displayed. I am monitoring Arduino platform which I know is sending data constantly.
Code:
Imports System.IO.Ports
Imports System.Text
Public Class ArduinoSerial
[code].....
I am really new into the vb.net. I am sure there are some horrible mistakes with this code but I am kind of stuck for the past 2 days on this one.
View 5 Replies
Dec 16, 2008
i am using serial communication to read from a plc.The plc will send a string :&H3A as a header byte then C(which is a variable that contains data)I want to read and mask out the header byte.I use the following code but cannot read anything.
Private Sub btnread_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnread.Click
Msg = SerialPort1.ReadExisting
count = Val(Mid(Msg, 1, 2))
Lblno.Text = count
[Code]...
View 1 Replies
Apr 1, 2009
I am trying to transmit the integer value 360 to serial port. but at micro controller i am getting the 3 bytes (33 36 30) its ASCII Values.So is there any way to transmit the 360's hex value 168 using two bytes only like 01 68 only?
View 2 Replies
Nov 7, 2008
I have noticed that I am getting a long delay while waiting for the serial ports to close.
Heres my code.
Code:
Using comI As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort(strPort(0))
[code].....
View 1 Replies
Jan 5, 2009
I am trying to recieve HEX data from a seriall device. Code is as below . but the required output is not correct. Some chracter code are not correct even in decimal. like for 80 i recieved 3F and for c0 also. for example i recived a string .
10 02 3F 00 10 03 3F 61
but in actual data should be
10 02 80 00 10 03 c0 61
Public Sub DataSeriallReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived
Dim buff As String
[Code].....
View 2 Replies
Apr 23, 2008
I'm trying to receive data from the serial port and display onto a text box in my gui in vb. I'm using xp pro sp2 and vb 2008 exp.What i've done so far:
- I'm able to send data successfully (tested) to the serial port
- I can dispaly what data is being sent (tested)
Steps taken:
- I have looked around on this forum for something similar to what I have but no similar posts are here
- Will look into MSDN help shortly
- Will also try some vb books I have lying around. But the problem is most of the vb books deal with sql server and database stuff and not really interfacing to hardware.
View 1 Replies
Sep 22, 2008
i have an application where i send data(a question in a "packet" of 8 digits) to an external controller via serial port, and then that controller sends me back some information(the answer, in a "packet" of 8 digits, not necesarily zeros and ones)I have develope a simply software that is getting the correct data form the controller, here it goes:[code]So now i can see how many times the code needs to enter the loop to get the "answer" from the module.Now i know that the code needs to do the loop from 5000 to 18000 times to get the answer each time!!!!, so that is why the software keeps getting freeze.I supose that that time is neccesary for the module to give the answer, so i think i can't get better respond times, but i would like the software not to get halt.
View 3 Replies
Jul 4, 2008
I'm writing an app with takes 3 readings off LCD displays via serial ports. The module which scans the serial ports is getting stuck in a loop for around 1.5 seconds. I need it to be much quicker than that. Is there a way I can setup a virtual serial port so I can run test it on my PC. Its very tedious and time consuming of making changes and visiting the machine its for.
View 1 Replies
Apr 21, 2008
I am new to socket communication. I found a few samples on the web and I managed to make my own host-client communication but i wanted to go a bit further and connect to port 80 of a server and it was just a disaster! First of all I know I can just use the functions that vb has itself but I want to make my own connections ... I have got some reasons I need this one! Do I really have to make them "connect" or just somehow without connecting I get the data? So I'm stack at the point that the connection is made ... it refuses to connect.
View 7 Replies
May 25, 2009
I have created a program using inpout32.dll to run my stepper motor . I can run stepper motor now but the problem is that it is running very slow! is there any better way i can run my motor fast as i want.
i used following method.
option explicit on
Dim myTime as object
public sub Form1
[Code]....
if i set the value of mytime less then 2000 my motor does'nt work at all. i tried also with the timer tool and i wrote the code in the tick event of timer but it is also very slow.
View 2 Replies
Feb 9, 2011
I have a barcode scanner that beside scanning the barcode it also snaps an image. I wrote a simple application that searching all ports locating in which one the scanner is connected and opening the port.
I can easily read any barcode and the send command to the scanner to pass me the image taken on the port, but i have a problem re-constructing the image from the bytes i read.
Code:
sendCommand()
Dim img(SP.BytesToRead) As Byte
SP.Read(img, 0, img.Length)
[Code]....
I can get the image from the scanner in any format needed (jpg,bmp etc) so no need to provide a precise solution just a general idea.
View 15 Replies
May 7, 2011
Now I'm doing a VB project about pc communications to a intelligent instrument with 485 serial port. I want to use API but I'm not good at it.
View 2 Replies
Feb 16, 2011
During Serial communications, is the echoing back usually done by the serial port interface or is it done by the UART at the far end?
View 10 Replies
Jan 27, 2011
I have a problem with something.I have a Arduino board I wan't to communicate with by serialport.
In "Form1", I'll retrieve values from the Arduino board, and I want it to calculate and display data in TextBoxes.How can I do this?[code...]
View 8 Replies
Oct 1, 2009
There seems to be a lot of discussion around about handling exeptions when a USB serial port device gets unplugged. What I want to know is how can one re-attach to it once it is plugged back in. The problem is that if you unplug a USB serial port device the app doesn't know it has gone and remains convinced it is still open. I have to close the app completely before I can re-attach to the device. I need a way to force it to close/go away.
View 2 Replies
Apr 3, 2011
What i want it to do is 'listen' to the lpt port, when a sensor is broken then display the time. there are two sensor to measure the time of the first and then the second sensor.How do i get VB to listen to the sensors which are on two different inputs of the lpt port and time stamp in micro seconds. I can get it to read the state of the input on mouse click but i need it to display the time in micro seconds when the input changes. i will then use the times from the two sensors to work out the time it took between both sensor changing.
View 5 Replies
May 9, 2010
What i want to do it be able to read the input of a pin on the parrallel port. I want to supply a constant voltage to the pin and when that voltage drops i want to jump to another procedure.
View 2 Replies
Dec 1, 2011
I have quite a bit of VB6 experience but now am trying to create my first VB.Net project. The project is very simple - it just needs to send 8-10 character strings from the PC serial port. The problem I'm seeing is that VB.Net is always sending out a 0x0A character after each 'WriteLine' call. Using VB6 it was necessary to manually send out any End Of Line characters. My application requires that no extra EOL characters be sent after the string.
View 2 Replies
Nov 11, 2008
i need to create an application where input are to be received by the barcode scanner.However, i am not suppose to use the textbox to do so. However i need to use the serial port to do so. Any one know how am i able to do that?
View 1 Replies
Sep 4, 2009
I have a VB.net app running on one computer, displaying text into 2 texboxes or labels.I need to see the two values in two sperate textboxes or labels from the two labels on another computer via a null modem serial adapter.
1st computer.
Code:
serialport1.writeline(label1.txt)
straight forward right?
2nd computer to read the data
Code:
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
dim s as new string = serialport1.readline()
label1.text = s
This is what I was thinking;
Code:
serialport.writeline(label1.text & label2.text
This would send the two values over the serial port. How would I seperate the two values and display them in two different texboxes?cannot use them together)Am I on the right path at all? Or using the serialport.writeline method won't work at all....
View 4 Replies