Home/Support/Support Forum/Prolific USB to Serial Com Port
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Prolific USB to Serial Com Port

0 votes
My project with PICDEM 2 PLUS DEMO BOARD, VC++ in windows 7. For communication with code and PIC board, I used UART/USB cable (USB serial port8). So far , I am able to connect with the PIC board and also able to receive/transmit data. But I want to use the Prolific USB to Serial Com Port. I tried every possible way(found in internet) like to update driver, change port number(initially when I connected with the Prolific cable, it takes the port4 automatically). Place the FTD2XX.dll file. But nothing help me out from this error. Below is the error

Unhandled exception at 0x00316329 in MovingArmProject.exe: 0xC0000005: Access violation reading location 0x00000000.

Here is a snap of my code, where it gives the error..
Code:
bool SerialCommunicator::SerialRx(void) { //the function to be called by the receiver thread BYTE buf[1024*8]; unsigned int read; static UINT16 crc; static UINT8 ptr_rxd_buffer = 0; UINT8 crc1, crc2; UINT8 c; do { read = port->ReadAvailable(buf,1000); // catch the received bytes, read= nb of received bytes in th buffer buf for( unsigned int k =0; k<read; k++) { c= buf[k]; if(receiverLocked) return 0; // if rxd buffer is locked immediately return // the rxd buffer is unlocked if((ptr_rxd_buffer == 0) && (c == '#')) // if rxd buffer is empty and syncronisation character is received { receivedPacket.data[ptr_rxd_buffer++] = c; // copy 1st byte to buffer crc = c; // init crc }else if (ptr_rxd_buffer < serialComms::RXD_BUFFER_LEN) // collect incomming bytes { if(c != '\r') // no termination character { receivedPacket.data[ptr_rxd_buffer++] = c; // copy byte to rxd buffer crc += c; // update crc }else // termination character was received { // the last 2 bytes are not subject for checksum calculation // they are the checksum itself crc -= receivedPacket.data[ptr_rxd_buffer-2]; crc -= receivedPacket.data[ptr_rxd_buffer-1]; // calculate checksum from transmitted data crc %= 4096; crc1 = (UINT8) ('=' + crc / 64); crc2 = (UINT8) '=' + crc % 64; // compare checksum to transmitted checksum bytes if((crc1 == receivedPacket.data[ptr_rxd_buffer-2]) && (crc2 == receivedPacket.data[ptr_rxd_buffer-1])) { // checksum valid receivedPacket.data[ptr_rxd_buffer] = '\r'; // set termination character receivedPacket.size = ptr_rxd_buffer + 1;// store number of received bytes receiverLocked = true; // lock the rxd buffer USART_ProcessRxData(); }else { // checksum invalid receiverLocked = false; // unlock rxd buffer } ptr_rxd_buffer = 0; // reset rxd buffer pointer } }else // rxd buffer overrun { ptr_rxd_buffer = 0; // reset rxd buffer receiverLocked = false; // unlock rxd buffer } } // for( unsigned int k =0; k<read; k++) }while(read>0); //end of do/while return 0; }

Here the error is given
Code:
read = port->ReadAvailable(buf,1000); // catch the received bytes, read= nb of received bytes in th buffer buf

Will be highly grateful If someone helps me out from this. Really in big problem

Thanks :)
asked Jun 17, 2013 in USB Serial by lara New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
You could try and contact Prolific directly, I believe they have C++ examples available on request.
answered Jun 24, 2013 by Egon New to the Community (9 points)
...