Subj : Re: Win32 RS-232 help To : borland.public.cpp.borlandcpp From : Jeff Baker Date : Fri Apr 30 2004 04:22 am Well, I'm an idiot! I found the problem. It's in my data types. The send_stream array was initialized as an INT data type (16-bit) and so was the received array. Since I am only allowed to send/receive 8-bit data types the whole process was screwed up from the beginning. I imagine that the device was trying to return a NAK condition but it was being stored in an incorrect format so I couldn't correctly identify the returned data. That also explains why the data was exactly the same every time. It was telling me that a transmission error or command error was received I just couldn't interpret it correctly. Anyway, here is the source code in it's working form. I will be using your idea (ReadFile(Com.handle,&Com.received[totalread],to_read,&read,NULL)) because the device will accept many commands and I don't know exactly how long the return stream will be for any of rest of them. void ComRoutine() { unsigned char x,send_stream[]={4,0,0,0,4,0}; DWORD to_write = 6; DWORD written = 0; DWORD to_read = 28; DWORD read = 0; gotoxy(1,8); textcolor(LIGHTGREEN); if (! WriteFile(Com.handle,send_stream,to_write,&written,NULL)) { textcolor(LIGHTRED); cprintf("Unable to write to %s!\r\n",Com.number); } else if (to_write != written) { textcolor(LIGHTRED); cprintf("Unable to write entire stream to %s (TIME_OUT)!\r\n",Com.number); } else cprintf("%s was written to successfully.\r\n",Com.number); if (! ReadFile(Com.handle,&Com.received[read],to_read,&read,NULL)) { gotoxy(1,9); textcolor(LIGHTRED); cprintf("Unable to read from %s!\r\n",Com.number); } else if (to_read != read) { gotoxy(1,9); textcolor(LIGHTRED); cprintf("Received %d bytes from %s, we expected %d (TIME_OUT)!\r\n",read,Com.number,to_read); } else { gotoxy(1,10); cprintf("REC: "); for(x = 0; x < (unsigned char)read; x++) { cprintf("%i ",Com.received[x]); clreol(); } } } Thanks again Bob and anyone else that was trying to get me an answer. I'll keep everyone up to date on my project. Btw, this software is for a digital multimeter (available from radio-shack) that has an RS-232 port on it. I decided to write my own software for it so I could learn to program in a Win32 environment. It will eventually be a GUI and not console and I will probably give it to anyone who wants a copy when it's done. Best Regards, - Jeff .