Error Writing Dcb1
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the setcommstate error 87 company Business Learn more about hiring developers or posting ads with us Stack Overflow
Buildcommdcb
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 setcommstate example million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Set DCB Fails When Attempting to Configure COM Port up vote 2 down vote favorite 2 I'm trying to
Setcommstate Function Failed
write a C++ MFC application that uses the serial port (e.g. COM8). Every time I try to set the DCB it fails. If someone can point out what I'm doing wrong, I'd really appreciate it. DCB dcb = {0}; dcb.DCBlength = sizeof(DCB); port.Insert( 0, L"\\\\.\\" ); m_hComm = CreateFile( port, // Virtual COM port GENERIC_READ | GENERIC_WRITE, // Access: Read and write 0, // Share: No sharing NULL, // Security: None OPEN_EXISTING, // setcommtimeouts The COM port already exists. FILE_FLAG_OVERLAPPED, // Asynchronous I/O. NULL // No template file for COM port. ); if ( m_hComm == INVALID_HANDLE_VALUE ) { TRACE(_T("Unable to open COM port.")); ThrowException(); } if ( !::GetCommState( m_hComm, &dcb ) ) { TRACE(_T("CSerialPort : Failed to get the comm state - Error: %d"), GetLastError()); ThrowException(); } dcb.BaudRate = 38400; // Setup the baud rate. dcb.Parity = NOPARITY; // Setup the parity. dcb.ByteSize = 8; // Setup the data bits. dcb.StopBits = 1; // Setup the stop bits. if ( !::SetCommState( m_hComm, &dcb ) ) // <- Fails here. { TRACE(_T("CSerialPort : Failed to set the comm state - Error: %d"), GetLastError()); ThrowException(); } Thanks. Additional Info: The generated error code is 87: "The parameter is incorrect." Probably Microsoft's most useful error-code. j/k c++ visual-studio-2008 mfc serial-port serial-communication share|improve this question edited Feb 27 '13 at 19:00 dsolimano 6,11832746 asked Nov 15 '10 at 21:01 Jim Fell 4,1601886154 You can mention the error code. –Amnon Nov 15 '10 at 21:05 @Amnon: Okay, I added the error-code info to my original post, but I don't think it helps much. –Jim Fell Nov 15 '10 at 21:09 add a comment| 4 Answers 4 active oldest votes up vote 8 down vote My money is on this: dcb.S
RS232 Hardware Interface RS232C History RS232C Likely problems Hardware Hardware Properties Bit Rates DTE/DCE Speeds Flow control The UART Types of UARTs Null modems Loop Back Plug Registers Port Addresses Table of registers DLAB IER IIR FCR
Windows Setcommstate
LCR LSR MCR Scratch Register Interfacing devices Waveforms Level converters 8250 UARTs Microcontrollers Programming About
C++ Dcb
Programming Open port Setup COM-port TimeOuts Purge COM-port Work with DCB Read and Write Event Adding Enumports Structure DCB COMSTAT OVERLAPPED getcommstate COMMTIMEOUTS PORT_INFO_* Work with DCB The port setting is carried out with the help of the DCB (Device-Control Block) structure.By filling this structure with needed values you can change the connection parameters to those needed http://stackoverflow.com/questions/4188782/set-dcb-fails-when-attempting-to-configure-com-port at the moment. To initially create the DCB structure with necessary general settings (baud rates, patity, number of bits, number of stop bits and flow control) is carried out by the BuildCommDCB function. Function syntax: BOOL BuildCommDCB (LPCTSTR lpDef, LPDCB lpDCB); This function is very useful as it sets the parameters of DCB structure which can be transmitted to the port just like *mode* command. If you remember MS DOS, null http://www.lookrs232.com/com_port_programming/api_work_with_dcb.htm modem cable and connection between two computers: sending a string returns the DCB structure. String example: baud=1200 parity=N data=8 stop=1 Function example: DCB dcb; ZeroMemory(&dcb,sizeof(DCB)); char buffer[100]; strcpy(buffer,"baud=1200 parity=N data=8 stop=1"); if (BuildCommDCB((char*)&buffer,&dcb)) { if (dcb.BaudRate == CBR_1200) cout << "Yes " << endl; } else cout << " error config DCB"; In case of successful termination BuildCommDCB() returns any value but zero, otherwize zero. This function replaces only explicit members with some exceptions. For 9600,n,8,1strings (not ending in x or p characters): fInX, fOutX,fOutXDsrFlow, fOutXCtsFlow are set to FALSE fDtrControl is set to DTR_CONTROL_ENABLE fRtsControl is set to RTS_CONTROL_ENABLE For 9600,n,8,1,x strings (ending in õ character): fInX, fOutX are set to TRUE fOutXDsrFlow,fOutXCtsFlow are set to FALSE fDtrControl is set to DTR_CONTROL_ENABLE fRtsControl is set to RTS_CONTROL_ENABLE For 9600,n,8,1,x strings (ending in p character): fInX, fOutX are set to FALSE fOutXDsrFlow,fOutXCtsFlow are set to TRUE fDtrControl is set to DTR_CONTROL_HANDSHAKE fRtsControl is set to RTS_CONTROL_HANDSHAKE After creating the DCB structure we must write it into the open port, it is done with the help of GetCommState function. When the structure is written into the port it may be needed to change the port parameters. The SetCommState function may be used to evade creating the structure anew . Function syntax: BOOL GetCommState (HANDL
Notes FAQ End of Support Problem Report Skip navigation PILATUS MYTHEN RIGI PPU 1. Why does the trigger not work? 2. Can I write the images with a different permission? 3. How is the PILATUS image oriented? 4. I https://www.dectris.com/faq_pilatus.html changed the network settings with "yast", now I get the message: "gethostbyname() : No such file or directory" in the camserver window right after startup. What happend? 5. I get an error like "*** DCB 1 DMA write was NOT successful; ...", what can I do? 6. After installing a new TVX/Camserver version I get: "dcb_count (2) must be >= NDCB (4) Bad return from dcb_initialize() Camera initialization error error writing -- press to exit" 7. After start up it is impossible to get past the DCB 0 read check in the initialization in the camserver window. 8. SetThreshold does not work after an upgrade of the the camserver software. 9. Can I switch between different camserver versions? 1. Why does the trigger not work? Please verify with anoscilloscopethat your trigger pulse is present and that the high level is more than 2 error writing dcb1 V.Never exceed 5 V!Check the Tech Specs for more details. The PILATUS EXT IN (Trigger Input) is terminated with 50Ω, your trigger source must be able to drive that load. Under certain circumstance the PILATUS cannot wait indefinitely for the trigger to arrive after arming, causing a "DMA Timeout" error. Please check the User Manual (Chapter 14 Camserver Commands, "ExtMTrigger", "ExtEnable") for details. Top 2. Can I write the images with a different permission? Yes! To write e.g. that only the det user gets read and write permissions (600, rw - -) please add the line "umask 077" to the.bashrc in the /home/detdirectory. 3. How is the PILATUS image oriented? The Pilatus images are seen from the perspective of the source. The left side of the image is the left side of the detector; top side of the image is top side of the detecto if you look into the reflecting mylar foil of the detector. Top 4. I changed the network settings with "yast", now I get the message: "gethostbyname() : No such file or directory" in the camserver window right after startup. What happend? The reason is probably a missmatch of the hostnames given in/etc/HOSTNAMEwith the hostname given in/etc/hosts.Make sure they match and restart after the change. Make sure they mat
be down. Please try the request again. Your cache administrator is webmaster. Generated Sat, 15 Oct 2016 05:03:19 GMT by s_wx1131 (squid/3.5.20)