Msdn serial port c




















Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Serial Port. Please rate your experience Yes No. Any additional feedback? I am doing some com port IO in C using visual studio. I have succesfully written the query to the port. Now the issue is reading back what is sent. IT receives data but its just jargon, probably my datatypes.

Copy Code. Posted 4-Aug am Member Add a Solution. Top Rated Most Recent. Accept Solution Reject Solution. A quick scan of your code suggests that you are setting it up to 57, baud and commenting that as 9, baud - one of those is wrong! And probably the parity as well I'd suggest that you use something like Hyperterminal to check your communications and make sure that you have exactly the right port settings before you leap into code - otherwise you are trying to debug everything at the same time with no idea of what is working so far.

When you have it working via hyperterminal, manually send a "known" command to the device, and capture its response. Then set your code up to do exactly the same thing, send the same command, and look carefully at the response before moving on to trying anything more advanced.

Posted 4-Aug am OriginalGriff. Member 4-Aug pm. Yeah, i definitely got the port settings right, the is a wrong comment. I write strings to the device to change its settings and it works, so now that I am writing code to it to send back data is where the issue is. OriginalGriff 4-Aug pm. Never leave wrong comments! They last longer than the damn code does Posted 4-Aug am CPallini. I am expecting the reply from the device to be in such format - 0.

CPallini 4-Aug pm. Any additional feedback? Namespace: System. Ports Assembly: System. Represents a serial port resource. In this article. SerialPort IContainer. SerialPort String. SerialPort String, Int SerialPort String, Int32, Parity. Gets a value indicating whether the component can raise an event.

Inherited from Component. Gets or sets the byte encoding for pre- and post-transmission conversion of text. Gets or sets the byte that replaces invalid bytes in a data stream when a parity error occurs. Gets or sets the port for communications, including but not limited to all available COM ports. CreateObjRef Type. Inherited from MarshalByRefObject.

Dispose Boolean. Equals Object. Determines whether the specified object is equal to the current object. Inherited from Object. Serves as the default hash function. GetService Type. Obtains a lifetime service object to control the lifetime policy for this instance. MemberwiseClone Boolean. Read Byte[], Int32, Int Read Char[], Int32, Int ReadTo String.

Write Byte[], Int32, Int Writes a specified number of bytes to the serial port using data from a buffer. Write Char[], Int32, Int Writes a specified number of characters to the serial port using data from a buffer. Write String.



0コメント

  • 1000 / 1000