Thanks a lot ppl.. It helps..
Subjugate
Posts
-
COM port -
Serial Communication, vb.netThanks for all the comment. i know that it is bad to use checkforillegalcrossthreadcalls = false but this is really the last resort as i still cant understand multi-threading. Next, port.read(bytearray, 0, bytetoread), it is bytearray and a few line above should be Dim bytearray as byte.. Sorry for the typo error. Noted for the encoding.ASCII.getstring. thanks for the advise. For the 2nd last line i don't get u.. Care to explain??
-
COM portCan i ask what must i enter to check if my port is open? Cause port.open = true is not able to use in this case. thanks.
-
Serial Communication, vb.neti already tried using hyper terminal before using my application. i know what is the result i am expecting but somehow when i used my application, the result i got is not complete. I tried changing some of the code and i test it again and it works and shown the complete result but when i test it the second time rd it fails again. I will show u might data received code below and see if u can help to see whether there is anything wrong with it. If port.bytesToRead > 0 then checkforillegalcrossthreadcalls = false Dimbytetoread as integer bytetoread = port.bytestoread Dim array as byte() = new byte(bytetoread - 1)() Dim linedata as string port.read(bytearray, 0, bytetoread) linedata = converttostring(bytearray) txtcommand.text = linedata port.close()
-
Serial Communication, vb.netActually i not sure if the complete output is shown. As i can only see part of it and the other part of it is missing. My buffer is 15 letters and it should be more den enough to fill the output. So if between the data received and read i do a sleep, will it works?
-
Serial Communication, vb.netI have a problem here with receiving data from the serial COM port. The i received is not in full, example if i suppose to received "password" but u only display pass. I know it is something wrong with my buffer but in my code i did not specified my buffer. have anyone encounter similar problem?? How can i set the buffer size of my data received?
-
RS232 CommunicationThanks for the info i think the breakpoint issue should be related to the threading problem as well.. btw tis is my code.. i didnt use any thread but dun know y i encounter the problem.. Private Delegate Sub SerialPort1_DataReceivedDelegate(ByVal sender As System.Object) Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles port.DataReceived If port.BytesToRead > 0 Then CheckForIllegalCrossThreadCalls = False Dim bytetoread As Integer bytetoread = port.BytesToRead Dim byteArray(bytetoread) As Byte Dim lineData As String port.Read(byteArray, 0, bytetoread) lineData = ConvertToString(byteArray) TxtCommand.Text = lineData End If End Sub Private Function ConvertToString(ByVal byteArray As Byte()) As String Dim tempStringToReturn As String = "" For Each bt As Byte In byteArray tempStringToReturn = tempStringToReturn + Convert.ToChar(bt) Next Return tempStringToReturn End Function
modified on Wednesday, February 25, 2009 10:46 PM
-
RS232 CommunicationYup.. This is the solution that i am using now. But i encounter something which i find very weird. After i use the checkforillegalCrossthreadcalls = false, i put breakpoints at certain part of my code and it seens to work as i can see the reply from my hardware. But when i remove all my breakpoints the cross thread error did not occur but there isnt any reply from my hardware as well. Have been trying to find the reason behind it but till now there is still isnt any explanation.
-
RS232 Communicationhi.. Thanks for the info. Current already tried the code and the error "cross-thread" occurred. Beside ur code i oso added a line which is txtCommand.text = lineData, from copy the string of data received to be display on the textbox and tis line causes the error. Any way to solved tis error??:confused:
-
RS232 CommunicationSo i should create an event as well right? By the way does the code u posted shows where the data will be display if the event is trigger? Cos i not sure if it is me that missed out anything, i cant find the displaying part.. thanks.
-
RS232 CommunicationSorry for the unclear question. Ya wat i was trying to do was to retrieve data from my serial comm port. I am able to send to the comm port but not able to receive. I already seen the link u posted. I seen to be wat i am looking for but only ting is in C#. So i was wondering if u have the .net version?
-
RS232 Communicationi got my control command to my external hardware. But the question now is i was unable to see the reply but i am sure there is a reply. Wat code should i insert to be able to see the reply?
-
Serial Communication [modified]Sorry for being so noob. Thanks anyway i got my command line to my hardware already. But the question now is i was unable to see the reply. How can i get the reply to be posted at a list box? Which means i need to display the reply from the port to list box.
-
Serial Communication [modified]I did already done the confirmation of the setting but still no reaction from my hardware. As i saw in the article i found on cp, there is another set of code suppose to be at the other pc so i wonder where should tis set of code be at if it is for hardware. Cant possibly put the code in a hardware. :confused:
-
Serial Communication [modified]This is the article which i found on cp about serial communication. I know it is quite simple if i am communicating between 2 computers but what if i am communicating with a hardware instead of computer? I have been told that it is the same between communication with computer or hardware but i just dun quite understand the concept. Current i have part of the code in my server pc and the other part i do not know how to apply. I dun seem to be able to open the port and send command to my hardware. Have anyone done a similar project and please advise me what to do? http://www.codeproject.com/KB/system/Serialport_COM.aspx[^][^]
modified on Monday, January 19, 2009 8:24 PM
-
Virtual Com portYes, i am using visual studio 2005.
-
Virtual Com portyes i did.. that's is why i don't understand why the error still appear.
-
Virtual Com portOk, sorry for asking stupid question. But i am quite new to serial communication. Another question i have is why when i Dim Withevents Port as serialPort = New Serialport, is labeled as error as undefined. But i have already imported the library.
-
Virtual Com portI look up google on the topic, but what they shows are all communication between computer. I cant find any which is communication with hardware.
-
Virtual Com portHi guys i need some help on virtual com port communication. I need to communicate to my external hardware via virtual com port. Now that i already gotten the command line for my hardware i just need to know how can i communicate with it and send the command. Will be greatly thankful if that is any example to allow me to understand better.