Hi all..
I'm trying to use someone else's design for a project i'm working on but have to compile some code that is pretty short but will not compile.
it is a program to load a video data stream file to memory and then send it to the parallel port uninterrupted using a pc in dos, data flow is controlled by the ACK input on the parallel port from an external CPLD.
here is the code...
Code:
/*********************************************
READ_PSK.C
READING SOFTWARE FOR .PSK FILES
May 16th 2004
(C) 2004 J.F. FOURCADIER F4DAY
*************************************************/
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
int main (void)
{
char nomfich[51];
FILE *data_file;
int base = 0x78C0; // output port address
int data_reg = base + 0;
int status_reg = base + 1;
unsigned char *buf;
unsigned long n;
int k = 0;
// FILE SIZE
// DATV_0 = 283968L
// DATV_1 = 7497408L
// DATV_3 = 1060800L
long filesize = 7497408L; // file size
buf = malloc(filesize);
clrscr();
data_file = fopen("C:\\DJGPP\\MYPRO\\datv_1.psk","rb");
if (data_file == 0)
{
printf("fopen failed\n");
printf("\n\nname of file should be datv_x.psk !\n");
exit(1);
}
else
{
printf("\nreading.....");
}
fread(buf,1,filesize,data_file);
fclose(data_file);
disable();
printf("\ntransmitting.....");
n = 0;
do
{
do
{
outportb(data_reg,*(buf+n));
// wait for next state on nAck :
do { } while (((inportb(status_reg)) | 0xBF) != 0xFF);
n++;
outportb(data_reg,*(buf+n));
// wait for next state on nAck :
do { } while (((inportb(status_reg)) | 0xBF) == 0xFF);
n++;
}
while(n <= (filesize - 1));
n=0;
k++;
}
while(!0); // endless loop
// while(k<500);
free(buf);
enable();
exit(0);
}
So the problem is when i try to compile i get this error for this line:
>>>>buf = malloc(filesize)
Error: Invalid conversion from 'void*' to 'unsigned char*'
Compiler i'm using is DJGPP with c and c++ parts installed.
i havent a clue really about pointers etc so i'm not sure what is wrong.....
can anyone help?
thanks
Rob