Author | Topic: Converting some VC++ to xBase++ ? | |
---|---|---|
Nestor Guido | Converting some VC++ to xBase++ ? on Sun, 09 May 2010 17:54:40 +0200 Hi Guys , I'm trying to convert some vc++ to xBase++ but have a problem with how to define the tx and rx buffers in xbase to call the dl's. Following is the Visual C code with its buffer definitions for tx and rx.....Then I show my attemp in the xbase code. Can someone tell me if I am right or wrong because all runs well ...but I do not get the results expected. Kind regards Nestor SAMPLE Visual C++ code: =============================== unsigned char tx[600], rx[600]; DWORD BytesWritten, AmountInRxQueue, BytesReturned; //Ping the port and check for correct response tx[1] = 0x30;//0 tx[2] = 0x31;//1 tx[3] = 0x30;//0 tx[4] = 0x38;//8 tx[5] = 0x30;//0 tx[6] = 0x30;//0 tx[7] = 0x30;//0 tx[8] = 0x33;//3 tx[9] = 0x30;//0 tx[10] = 0x34;//4 tx[11] = 0x46;//F tx[12] = 0x46;//F tx[13] = 0x30;//0 tx[14] = 0x30;//0 tx[15] = 0x30;//0 tx[16] = 0x30;//0 FT_Write(m_ftHandle, tx, 16, &BytesWritten); //pos and byteswritten = 16 FT_GetQueueStatus(m_ftHandle, &AmountInRxQueue); //amountinrxqueue ...indicates how many bytes in buffer FT_Read(m_ftHandle, rx, AmountInRxQueue, &BytesReturned); && reponse back into rx @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ SAMPLE xBase Code: ================== **Note all dll calls have previously been prepared Local ctx:= "0108000304FF0000"+Space(584) && Transmit buffer Local crx:= Space(600) && Receive buffer Local nBytesWritten:=0, nAmountInRxQueue:=0, nBytesReturned:=0 DllExecuteCall( FT_Write , nFTDevice_Handle, ctx ,16, @nBytesWritten) DllExecuteCall( FT_GetQueueStatus, nFTDevice_Handle, @nAmountInRxQueue) DllExecuteCall( FT_Read, nFTDevice_Handle, @crx, nAmountInRxQueue, @nBytesReturned) | |
Pablo Botella | Re: Converting some VC++ to xBase++ ? on Sun, 09 May 2010 21:27:26 +0200 Hi, Just 1 diference betwen the C++ and the Xbase++ code PRG: Local ctx:= "0108000304FF0000" + ... string start at position 0 of the buffer !!!! cpp: tx[1] = 0x30;//0 string start at position 1 of the buffer !!!!!! tx[600] is not initialitzed so position 0 of the buffer can contain just anything. At first look seems that your Xbase++ code is OK but the C++ sample is wrong, unless you found anything in the docs that told you that the first byte must be reserved for any special purpose. Regards, Pablo | |
Nestor Guido | Re: Converting some VC++ to xBase++ ? on Mon, 10 May 2010 08:12:36 +0200 Hi Pablo, Thank you....Maybe I have made a mistake because I thought I would simplyfy the the example. The original: Question what would be the index value for the first index possition tx [pos++] and and if I where to use pos instead of 16 in the FT_write what would the value of pos be. My guess is that the first tx[pos++] ( pos would equal 0)....then pos would be equal to 16 if I were to use it in the FT_Write call function. Thanking you in antisipation. Nestor unsigned char tx[600], rx[600]; DWORD BytesWritten, AmountInRxQueue, BytesReturned; int pos=0; //Ping the port and check for correct response tx[pos++] = 0x30;//0 tx[pos++] = 0x31;//1 tx[pos++] = 0x30;//0 tx[pos++] = 0x38;//8 tx[pos++] = 0x30;//0 tx[pos++] = 0x30;//0 tx[pos++] = 0x30;//0 tx[pos++] = 0x33;//3 tx[pos++] = 0x30;//0 tx[pos++] = 0x34;//4 tx[pos++] = 0x46;//F tx[pos++] = 0x46;//F tx[pos++] = 0x30;//0 tx[pos++] = 0x30;//0 tx[pos++] = 0x30;//0 tx[pos++] = 0x30;//0 FT_Write(m_ftHandle, tx, 16, &BytesWritten); //pos and byteswritten = 16 FT_GetQueueStatus(m_ftHandle, &AmountInRxQueue); //amountinrxqueue ...indicates how many bytes in buffer FT_Read(m_ftHandle, rx, AmountInRxQueue, &BytesReturned); && reponse back into rx "Pablo Botella" <pb_no_spam_@_remove_all_betwen_underscores_xbwin.com> wrote in message news:6281971e$69ad1cfe$4c4f6@news.alaska-software.com... > Hi, > > Just 1 diference betwen the C++ and the Xbase++ code > > PRG: Local ctx:= "0108000304FF0000" + ... string start at position 0 of > the buffer !!!! > cpp: tx[1] = 0x30;//0 string start at position 1 of the buffer !!!!!! > > tx[600] is not initialitzed so position 0 of the buffer can contain just > anything. At first look seems that your Xbase++ code is OK but the C++ > sample is wrong, unless you found anything in the docs that told you that > the first byte must be reserved for any special purpose. > > Regards, > Pablo | |
Pablo Botella | Re: Converting some VC++ to xBase++ ? on Mon, 10 May 2010 08:58:05 +0200 tx[0] = 0x30; pos = 0+1 .... and finally tx[15] = 0x30; pos = 15 + 1 So pos = the length of the string |