|
|
I believe that the ‘bios.h’ header was Borlands equivalent of Microsofts C ‘dos.h’ header; although I think other venders provided a header with the same name. The header ‘perce.h’ sounds like a custom header (created by original developer). You need to look at the code to see where bios/dos (low level system calls) are being made, as some of these calls will no longer work and will generate a system error on modern OSs, due to security issues. Look at the code an try to figure out which functions are making BIOS calls like that require code like reg.ax = 1 , as you will have to find a way to replace those functions with an equivalent one.
Good Luck!
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Dear all,
Now I'm writing a small program to communicate via RS232 with 3964 protocol, however Idon't understand why I cannot compile this source code. Any body please help me solve this problem.
<br />
<br />
#include <stdio.h><br />
#include <conio.h><br />
#include <io.h><br />
#include <fcntl.h><br />
#include <string.h><br />
#include <dos.h><br />
#include <bios.h><br />
#include "perce.h"<br />
<br />
#define ESC 27<br />
<br />
void interrupt(*oldvect_ser)(); <br />
extern void interrupt int_sio(); <br />
extern void restore_8250 (void); <br />
extern void init_8250 (void);<br />
extern void send_tele (char *, short);<br />
extern WORD state, receive_counter, protocol_error;<br />
extern BYTE receive_buffer[];<br />
<br />
BYTE choice,sio_eoi; <br />
BOOL receive, autosend; <br />
WORD Com_basis,len;<br />
BYTE send_buffer[BUFFER_MAX]; <br />
BYTE tmp_buffer[BUFFER_MAX]; <br />
BYTE *mode,*port;<br />
<br />
<br />
void warte (void)<br />
{<br />
long i;<br />
<br />
for (i=0;i<500000;i++) i = i;<br />
}<br />
<br />
void menue (void)<br />
{<br />
clrscr();<br />
printf ("\n\n");<br />
printf ("Final Version of KUKAVISION.EXE \n");<br />
printf ("Serial device with 3964R protocol mod. P.S. 08.08.03\n\n");<br />
printf ("[1] send teststring [4] COM 1 \n");<br />
printf ("[2] getNum [5] COM 2 \n");<br />
printf ("[3] getDat [6] reset protocol\n");<br />
printf (" [ESC] quit\n");<br />
printf ("Aktueller Port: %s\n",port);<br />
printf ("Mode : %s\n", mode);<br />
printf ("Number of elements: %d\n",numEl);<br />
printf ("Element index: %d\n",elementIndex);<br />
printf ("Element Data: %s\n---------\n", &send_buffer[0]);<br />
}<br />
<br />
void send_telegram (BYTE *buffer)<br />
{<br />
if ((len = strlen (buffer)) > 0)<br />
{<br />
send_tele (buffer, len);<br />
warte ();<br />
warte ();<br />
warte ();<br />
if (state == E1)<br />
{<br />
state = RUHE;<br />
protocol_error=2;<br />
}<br />
else protocol_error=6;<br />
}<br />
<br />
<br />
<br />
void monitoring (void)<br />
{<br />
short i;<br />
printf("-> : ");<br />
for (i=0;i<receive_counter;i++)<br />
{<br />
if(isprint(receive_buffer[i])) printf("%c", receive_buffer[i]);<br />
else printf("0x%X", receive_buffer[i]);<br />
} <br />
printf("\n");<br />
receive = FALSE;<br />
}<br />
<br />
<br />
void main ()<br />
{<br />
int sio_int_nr,i;<br />
int j;
char *fields;<br />
BOOL quit = FALSE;<br />
Com_basis = 0x3F8 ; <br />
sio_int_nr = 0xC; <br />
sio_eoi=0x<br />
port= "COM 2";<br />
oldvect_ser = getvect(sio_int_nr);<br />
setvect(sio_int_nr,int_sio);<br />
state = RUHE;<br />
choice = protocol_error = 0;<br />
receive = autosend = FALSE;<br />
mode = "ready";<br />
elementIndex=0;<br />
init_8250 ();<br />
menue ();<br />
do<br />
{<br />
if (bioskey(1))<br />
{<br />
choice = bioskey(0);<br />
switch (choice)<br />
{<br />
case ESC: <br />
quit = TRUE;<br />
break;<br />
case '1': <br />
send_telegram (&send_buffer[0]);<br />
break;<br />
case '2': <br />
strcpy(&receive_buffer[0],"getNum");<br />
receive=TRUE;<br />
mode = "getNum";<br />
menue ();<br />
break;<br />
case '3': <br />
strcpy(&receive_buffer[0],"getDat");<br />
receive=TRUE;<br />
mode = "getDat";<br />
<br />
menue ();<br />
break;<br />
case '4': <br />
Com_basis=0x3F8;<br />
sio_int_nr = 0xC; <br />
port="COM 1";<br />
menue ();<br />
break;<br />
case '5': <br />
Com_basis=0x2F8;<br />
sio_int_nr = 0xB;<br />
port="COM 2";<br />
menue ();<br />
break;<br />
case '6': <br />
state = RUHE;<br />
break;<br />
default:;<br />
}<br />
choice = 0;<br />
}<br />
if (receive)<br />
{<br />
monitoring (); <br />
if (strcmp("getNum",&receive_buffer[0]) == 0) <br />
{<br />
elementIndex=0;<br />
printf("getNum erhalten\n");<br />
if( imaqReadFile() == -1)<br />
printf("Fehler beim Lesen der Datei\n");<br />
else <br />
{<br />
numEl = imaqGetNbElements(); <br />
menue();<br />
elementIndex=1;<br />
}<br />
}<br />
if (strcmp("getDat",&receive_buffer[0]) == 0) {<br />
if(elementIndex > numEl){<br />
printf("Keine Daten mehr vorhanden\n");<br />
for (i=0;i<BUFFER_MAX;i++)<br />
sprintf(&send_buffer[i],"\0"); <br />
imaqClose();<br />
}<br />
else <br />
{<br />
dataErr = imaqGetData(elementIndex, send_buffer);<br />
if (dataErr==0)<br />
send_telegram (&send_buffer[0]); <br />
menue();<br />
elementIndex++;<br />
}<br />
}<br />
if (protocol_error)<br />
{<br />
switch (protocol_error)<br />
{<br />
case 1:<br />
printf("\nCRC-Error (NAK->) !!\n");<br />
break;<br />
case 2:<br />
printf("\nno response (DLE) !!\n");<br />
break;<br />
case 3:<br />
printf("\nno send quitt (DLE) !!\n");<br />
break;<br />
case 4:<br />
printf("\nReceive buffer overflow !!\n");<br />
break;<br />
case 5:<br />
printf("\nrepeating telegram (->NAK) !!\n");<br />
break;<br />
case 6:<br />
printf("\nno teststring defined\n");<br />
break;<br />
case 7:<br />
printf("\nSTX\n");<br />
break;<br />
default:;<br />
}<br />
protocol_error = 0;<br />
}<br />
} while (!quit);<br />
restore_8250 ();<br />
setvect(sio_int_nr,oldvect_ser);<br />
}<br />
|
|
|
|
|
It would be nice that you tell us at least what the exact error message is and to paste only relevant code. I'm sure if you did that, you would already have an answer (I seriously doubt that anybody wants to go to your complete source and hunt for your problem).
Man, the error messages supplied by your compiler ARE usefull.
|
|
|
|
|
Hi guys!
Has anyone tried to port a desktop application in Visual C++ to
embedded/DSP? What should be considered or steps to take in
porting?
|
|
|
|
|
apoc83 wrote: a desktop application in Visual C++
What does that mean exactly ? Is it a console application, a Win32 app, does it use MFC ? ...
apoc83 wrote: embedded/DSP?
Is there even an OS running on your DSP ? What compiler are you using ? ...
Your question is too vague to be able to give you a correct answer.
|
|
|
|
|
Sorry, porting C++ console application to Code Composer studio.
|
|
|
|
|
I'm using a singly linked list of structures. Each structure has 3 cstrings and a pointer in it. The reason I'm using cstrings and not strings is that I'm populating a list box that has to stay persistent. I could use strings but I would have to use .c_str() every time. I wrote the code for the linked list with help from wikepedia and a book and it works, the problem is that I have a memory leak. I still can't find any error in the code though.
My question is, are there any special issues with cstrings that would cause a memory leak in this situation? Are their any known problems with their destructors?
Here is the function that destroys the linked list if you wouldn't mind checking it:
CStringLListElement* CurrentPtr = HeadPtr;
CStringLListElement* BackPtr = HeadPtr;
while(CurrentPtr != NULL)
{
BackPtr = CurrentPtr;
CurrentPtr = CurrentPtr->ForwardPtr;
delete BackPtr;
}
Here is part of the error message from the compiler (I only listed a few lines):
Detected memory leaks!
Dumping objects ->
{299} normal block at 0x010A65A8, 152 bytes long.
Data: <h w="" 200310=""> 48 EC 57 00 CD CD CD CD 32 30 30 33 31 30 00 CD
{298} normal block at 0x010A64D0, 152 bytes long.
Data: << W 200310 > 3C EC 57 00 CD CD CD CD 32 30 30 33 31 30 00 CD
{297} normal block at 0x010A63F8, 152 bytes long.
Data: < W 200310 > E4 EB 57 00 CD CD CD CD 32 30 30 33 31 30 00 CD
{296} normal block at 0x010A6320, 152 bytes long.
Data: < W 200310 > F8 EB 57 00 CD CD CD CD 32 30 30 33 31 30 00 CD
{295} normal block at 0x010A6248, 152 bytes long.The program '[2212] CS_Project.exe: Native' has exited with code 0 (0x0).
Thanks for looking at this. I would appreciate any help.
|
|
|
|
|
I haven't seen a CString leak before. Those unfreed blocks are CString objects for sure?
Try adding this to your source files so you can see the file/linenumber where the object was
allocated in the leak dump:
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
The code looks good to me....I guess it could be shortened a line:
CStringLListElement* CurrentPtr = HeadPtr;
while(CurrentPtr != NULL)
{
CStringLListElement* BackPtr = CurrentPtr;
CurrentPtr = CurrentPtr->ForwardPtr;
delete BackPtr;
}
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
I would be about 99.9999999999999999999999999999999 % sure the leak is in the code you wrote, not in CString.
led mike
|
|
|
|
|
led mike wrote: I would be about 99.9999999999999999999999999999999 %
I am 100% percent sure the leak is in his code.
|
|
|
|
|
CoffeeAddict19 wrote: Detected memory leaks!
Dumping objects ->
{299} normal block at 0x010A65A8, 152 bytes long.
Data: 48 EC 57 00 CD CD CD CD 32 30 30 33 31 30 00 CD
{298} normal block at 0x010A64D0, 152 bytes long.
Data: << W 200310 > 3C EC 57 00 CD CD CD CD 32 30 30 33 31 30 00 CD
{297} normal block at 0x010A63F8, 152 bytes long.
Data: < W 200310 > E4 EB 57 00 CD CD CD CD 32 30 30 33 31 30 00 CD
{296} normal block at 0x010A6320, 152 bytes long.
Data: < W 200310 > F8 EB 57 00 CD CD CD CD 32 30 30 33 31 30 00 CD
{295} normal block at 0x010A6248, 152 bytes long.The program '[2212] CS_Project.exe: Native' has exited with code 0 (0x0).
You can go to memory leak source, by double clicking these lines.
|
|
|
|
|
Hello,
I am new to VC++. I am supposed to build an application which includes generating reports dynamically using data in a database based on what the user selects. i have heard of something called as Crystal Report.
But I am not sure whether that is the right tool to use because I dont know much about that software. Is this the simplest solution to generating reports. Is it possible to do the same without using additional software? Which are the other options, if any?I am using Visual C++ 6.0. Crystal reports is not bundled into it.
Kindly help
|
|
|
|
|
Well, Crystal reports surely beats building reports by hand. I have used it for 10 years. It does the job fairly well and can produce decent looking or even spectacual reports with niceties like drill-down, graphs and stuff.
It is not expensive either. Downside is that documentation is sorely lacking especially for C++. They seem to think everyone is using VB
See:
http://technicalsupport.businessobjects.com/KanisaSupportSite/supportcentral/supportcentral.do?id=m1
|
|
|
|
|
Thank you so much for your reply.
Anders Gustafsson wrote: Downside is that documentation is sorely lacking especially for C++.
In what way is it lacking for visual c++. Is it farily straightforward to use....Because i am really hard pressed for time on this project. Are ther some tutorials for that?
Also, I have heard about a software called Visual reports from sparrow-technologies. How does this compare in terms of ease of usage and display properties. Also, this maybe wandering away from the topic a bit, but could you please recommmend some good tutorials for VC++ 6.
I am building a Gui for a database application.
Thank you again.
|
|
|
|
|
I cannot really compare it to anything else. When we decided to convert our payroll app to C++ in 1997, Crystal was pretty much the only game in town. It is also quite widely used. It has a nice GUI editor where you create report files by pulling data from a database source. The finished report is an .rpt file that you distribute and use the CR engine to display/print.
I suggest you download rdccpp85.exe from the BusinessObjects site. It has an example on how to call a report from C++. It lacks examples on how to pass an argument to it though, but ask if you need it
Also. I have two books on Cr9 on the shelf. Both are OK. One is Mastering Crystal Reports 9 from Sybex, the other is Crystal Reports Essential by Jill K Howe from Premier Press. Both are avalable from Amazon.
I had a quick chec at the Visual Reports site. It seems similar. I also see that there is an eval version you can download. for us, we stick with CR despite it's quirks. We are taking about a commercial app here, with a lot of reports. So I would rather not have to recreate those. FWIW, we are licensed for CR version XI, but selected to use CR9 for now, "because that is what the bulk of the other vendors use"
Your selection will also depend on what fees if any are on redistribution. A crystal developer license allows pretty much unlimited distribution.
|
|
|
|
|
Hi
I have a server app that I'm developing. When I call the bind function that is in my BindStructOnSocket function, depending how I filled my sockaddr_in structure, occurs an different error.
If I fill my sockaddr_in.sin_addr field like this :
<br />
SocketStruct->sin_addr.s_addr = INADDR_ANY;<br />
When I call accept function my app enters in a infinite loop.
If I fill my sockaddr_in.sin_addr field like this :
<br />
char cName[30];<br />
gethostname(cName, 30);<br />
hostent * theHost;<br />
theHost = gethostbyname(cName);<br />
SocketStruct->sin_family = AF_INET;<br />
SocketStruct->sin_port = htons(2500);<br />
SocketStruct->sin_addr = *((in_addr*)theHost->h_addr_list);<br />
When I call accept I get the WSAEADDRNOTAVAIL error.
My queswtion is WHY?
I'm developing this with Visual C++ 6
Below my code
Tks for the support
<br />
SOCKET CreateSocket()<br />
{<br />
SOCKET theSocket;<br />
WORD wVersion = MAKEWORD(2, 0);<br />
WSADATA wsStartup;<br />
WSAStartup(wVersion, &wsStartup);<br />
theSocket = socket(AF_INET, SOCK_STREAM, 0);<br />
if(theSocket == INVALID_SOCKET)<br />
{<br />
MessageBox(NULL, "Socket não criado", "Erro", MB_ICONERROR|MB_OK);<br />
return INVALID_SOCKET;<br />
}<br />
return theSocket;<br />
}<br />
<br />
void CreateSocketStruct(sockaddr_in * SocketStruct)<br />
{<br />
SocketStruct->sin_family = AF_INET;<br />
SocketStruct->sin_port = htons(2500);<br />
SocketStruct->sin_addr.s_addr = INADDR_ANY;<br />
for(int i = 0 ; i < 8 ; i++) SocketStruct->sin_zero[i] = 0;<br />
char * cTemp;<br />
cTemp = inet_ntoa(SocketStruct->sin_addr);<br />
MessageBox(NULL, cTemp, "", MB_OK);<br />
}<br />
<br />
int BindStructOnSocket(SOCKET currSocket, sockaddr_in * SocketInfo)<br />
{<br />
int iTemp = bind(currSocket, (sockaddr*)SocketInfo, sizeof(sockaddr));<br />
if(iTemp != 0)<br />
{<br />
int i = WSAGetLastError();<br />
char cTemp[5];<br />
if(i == WSAEADDRNOTAVAIL)MessageBox(NULL, "", "Erro", MB_OK);<br />
}<br />
return iTemp;<br />
}<br />
|
|
|
|
|
The second method won't work if there's no adapter associated with the address you specify.
The first method (using INADDR_ANY) should be correct. There's maybe something wrong with your
accept processing.
Is this the server's listening socket you are using the above code on?
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Mark Salsbery wrote: Is this the server's listening socket you are using the above code on?
Exactly, I'm testing this code in my house but the problem persists
|
|
|
|
|
So once your listening socket is bound and listening, there's an infinite loop on accept?
Do you mean it just sits (blocked) in the accept() call?
Assuming your socket(), bind(), and listen() calls all succeed (no errors) then this is the
correct behavior for a blocking socket when you call accept(). accept() will block until there's
a connect request.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
No, there aren't an infinite loop on accept. And yeah, it just sits in the accept call.
|
|
|
|
|
Then it is working as written.
I'm guessing you need that to be asynchronous instead of halting the thread, correct?
If so, you can do one of these:
1) Leave the listener socket in blocking mode and put the accept call in a different thread.
2) Use WSAAsyncSelect() to place the socket in non-blocking mode and get a window message when
a connection attempt is received. Then call accept() in response.
3) Use WSAEventSelect() to place the socket in non-blocking mode and have an event signalled when
a connection attempt is received. Then call accept() in response (also requires a separate thread
to be effective).
4) Use an IO Completion Port (advanced).
*edit* Fixed some typnig.
Mark
-- modified at 17:33 Thursday 1st March, 2007
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
5) Buy your Fish Filet at McDonalds
led mike
|
|
|
|
|
Indeed! Dammit now I'm hungry.
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Where Name is a BSTR:
TRACE("\nFIELD[%d]: %s",j,(LPCTSTR)Name);
or
TRACE("\nFIELD[%d]: %s",j,Name);
Both just print the first char??
Anders G
|
|
|
|
|