Now I do some protocol about the RS485 communication. My communication was piont(Master PC) to multi-point(Microcontroller). In order to decrease bytes during communication. I defined some of bits as command, some bits as address in one byte. So I have encode and decode procedure. When the data was returned by slaver station, I got ASCII data. I don't want to get the ASCII data. I want to receive binary data directly. For example, I received "A", its real value should be 65(b01000001). This sample, I set return as string. Whether the return as byte array of serial component in VB can get 65? Because I have no sample about this one. I only know how to use "return as string". Anybody can help me and give me one simple sample?? Thank you very much.
I'm not quite sure I understand what you are trying to do. Here is an example Serial Instrument Control in Visual Basic. Let me know if this is what you are looking for. If you still have questions repost. Have a great day!
I've attached the program below. Here is the description:
This program demonstrates how to perform serial instrument communication using Visual Basic 6.0. The example was written to communicate with an NI Instrument Simulator. Communicating with other instruments should be possible by modifying the example which uses 9600 baud, 8 data bits, no parity and hardware handshaking.
Thank you! Jenk! I got your sample. But I know that that is MSComm component. Actually, I wanted to know NI's serials component. As I know MSComm's input data can be set to Binary. But I'am not sure the function of NI's Serial component.
I'm not sure what you mean by "I wanted to know NI's serials component. As I know MSComm's input data can be set to Binary. But I'am not sure the function of NI's Serial component." Can you expand a little bit on that? Thanks!
NI's serial component was in the measurement studio. If you install the measurement studion in your computer, you can open Visual Basic then add National Instructments CW Instr 6.0. After that, you can see serial and GPIB components in your component chart. Serial component was almost the same to mscomm. It can be used easier on project. Now I have settle the issue of byte array. I have changed the development tool to C++ builder.
HASC: MOV B,A ;暂存待转换的单字节十六进制数 LCALL HAS1 ;转换低四位 XCH A,B ;存放低四位的ASCII码 SWAP A ;准备转换高四位 HAS1: ANL A,#0FH ;将累加器的低四位转换成ASCII码 ADD A,#90H DA A ADDC A,#40H DA A RET ************** ASCII TO HEX ************* ASM SUB ASCH: CLR C SUBB A,#30H JNB ACC.4,ASH1 SUBB A,#7 ASH1: RET
VB conversion function ASC("A") return to ASCII "65" HEX(65) return to HEX : "01000001"