예제 #1
0
bool afqt::recvMessage( QTcpSocket * qSocket, af::Msg * msg)
{
   char * buffer = msg->buffer();
   int bytes = readdata( qSocket, buffer, af::Msg::SizeHeader, af::Msg::SizeBuffer);
   if( bytes < af::Msg::SizeHeader)
   {
      AFERROR("qtcom::recvMessage: read message header.\n");
      return false;
   }

   msg->readHeader( bytes);

   int msgtype = msg->type();
   int datalen = msg->int32();

   if( msgtype >= af::Msg::TDATA)
   {
      buffer = msg->buffer(); // buffer may be changed to fit new size
      int readlen = datalen - bytes + af::Msg::SizeHeader;
      if( readlen > 0)
      {
         bytes = readdata( qSocket, buffer+bytes, readlen, readlen);
         if( bytes < readlen)
         {
            AFERROR("qtcom::recvMessage: read message data.\n");
            msg->setInvalid();
            return false;
         }
      }
   }
   return true;
}
예제 #2
0
/*
MAIN::MESSAGE* MAIN::getmessage(){
	int DataHead[2];
	readdata((char*)DataHead,8);
	MESSAGE* buffer =(MESSAGE*) new BYTE[DataHead[1]+8];
	buffer->Datasize=DataHead[1];
	buffer->Mid=DataHead[0];
	readdata((char*)buffer->DATA,buffer->Datasize);
	return buffer;
}
*/
map<string,wstring>* MAIN::getmessage(){
	int len;
	readdata((char*)&len,4);
	//4 bytes for length and last one for \0
	RUNNER* buffer = (RUNNER*)new BYTE[len+5];
	memset(buffer,0,len+5);
	buffer->Datasize=len;
	readdata((char*)buffer->DATA,len);
	stringstream stm(buffer->DATA);
	string line;
	map<string,wstring> *ret=new map<string,wstring>();
	while(getline(stm,line)){
		string::size_type pos = line.find(':');
		if(pos==string::npos)
			throw runtime_error("Bad Config");
		WCHAR* buf=GetWideChar(line.substr(pos+1,line.length()-pos-1).c_str());
		(*ret)[line.substr(0,pos)]=buf;
		delete[] buf;
	}
	if((*ret)["standard-in"][0]=='.' && (*ret)["standard-in"][1]=='/')
		(*ret)["standard-in"]=(*ret)["working-directory"]+(*ret)["standard-in"].substr(2,(*ret)["standard-in"].length()-2);
	if((*ret)["standard-out"][0]=='.' && (*ret)["standard-out"][1]=='/')
		(*ret)["standard-out"]=(*ret)["working-directory"]+(*ret)["standard-out"].substr(2,(*ret)["standard-out"].length()-2);
	if((*ret)["standard-err"][0]=='.' && (*ret)["standard-err"][1]=='/')
		(*ret)["standard-err"]=(*ret)["working-directory"]+(*ret)["standard-err"].substr(2,(*ret)["standard-err"].length()-2);
	wstring cmd=(*ret)["command"];
	if(cmd[0]=='.'&&cmd[1]=='/')
		(*ret)["command"]=(*ret)["working-directory"]+cmd.substr(2,cmd.length()-2);
	return ret;
}
int main(){
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);

    while(readdata()) process();
    return 0;
}
예제 #4
0
static long readfile(int sock,FILE *f)
{
	int partition_id;
	if (!sendLong(sock, partition_id))
        return kReadFileFailure;
    long filesize;
    if (!readlong(sock, &filesize))
        return kReadFileFailure;
    if (filesize > 0)
    {
        char buffer[1024];
        do
        {
            int num = min(filesize, sizeof(buffer));
            if (!readdata(sock, buffer, num))
                return kReadFileFailure;
            int offset = 0;
            do
            {
                size_t written = fwrite(&buffer[offset], 1, num-offset, f);
                if (written < 1)
                    return kReadFileFailure;
                offset += written;
            }
            while (offset < num);
            filesize -= num;
        }
        while (filesize > 0);
    }
    return partition_id;
}
예제 #5
0
int main()
{
	readdata();
	solve();

	return 0;
}
예제 #6
0
void CIRDriver::DaemonThreadProc(void)
{
	/* Accept client connections,		*/
	/* and watch the data buffer.		*/
	/* When data comes in, decode it	*/
	/* and send the result to clients.	*/
	unsigned long data;
	char *message;

        Cwinlirc *app = (Cwinlirc *)AfxGetApp();

	for(;;)
	{
		if(GetData(&data)==false)
		data=readdata(0,DaemonThreadEvent);
		use_ir_hardware=true;
		message=decode_command(data);
		if(message!=NULL)
		{
			//DEBUG("decode_command successful\n");
			drvdlg->GoGreen();
			app->server->send(message);
		}
		else
		{
			//DEBUG("decode_command failed\n");
		}
	}
}
예제 #7
0
/*---------------------------------------------------------------------------*/
static uint8_t
readdatabyte(void)
{
  uint8_t r;
  readdata(&r, 1);
  return r;
}
예제 #8
0
파일: cli.c 프로젝트: idaohang/gpsr-1
int main( int argc, char **argv )
{
	char file[MAX_FILENAME_LEN + 1];
	char *line, *prompt="> ";
	int i;

	if ( argc == 2 )
		ystrncpy( file, argv[1], MAX_FILENAME_LEN );
	else
		yerror( "missing filename\n" );

	restores( file );
	prints();
	restorer( file );

	for( i = 0; i < status.datan; i++ )
		readdata( status.dataf[i], i );

	port = gp_open( "400x400" );
	using_history();
	stifle_history(1000);
	sprintf( historyfile, "%s/%s", getenv("HOME"), HISTORYFILE );
	if ( !access (historyfile, R_OK) )
		if ( read_history(historyfile) )
			perror( "reading history" );
	while (1) {
		line=readline( prompt );
		if ( line ) {
			add_history( line );
			parser( line );

		} else printf( "\n" );
	}
	return 0;
}
예제 #9
0
int main()
{
	readdata();
	super_Gauss();

	return 0;
}
예제 #10
0
static bool readlong(int sock, long *value)
{
    if (!readdata(sock, value, sizeof(value)))
        return false;
    *value = ntohl(*value);
    return true;
}
예제 #11
0
파일: read.c 프로젝트: bitursa/maos
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
    file_t *fp;
    char *fn=NULL;
    int start=0, howmany=0;
    switch(nrhs){
    case 3:
	start=(long)mxGetScalar(prhs[2]);//starting block to read. matlab index.
    case 2:
	howmany=(long)mxGetScalar(prhs[1]);//do not break
    case 1:
	fn=mx2str(prhs[0]);
	break;
    default:
	usage();
    }
    if(howmany>0){
	if(start>0){
	    start--;//convert to C index.
	}
	if(start<0){
	    start=0;
	}
    }
    fp=zfopen(fn,"rb");
    if(!fp){
	perror("zfopen");
	error("Unable to open file: %s\n", fn);
	return;
    }
    free(fn);
    switch(nlhs){
    case 0:
    case 1:
	plhs[0]=readdata(fp, NULL, start, howmany); break;
    case 2:
	plhs[0]=readdata(fp, &plhs[1], start, howmany); break;
    default:
	usage();
    }
    if(start==0 && howmany==0){
	int res=zfeof(fp);
	if(res){
	    warning("There is unread data: res=%d\n", res);
	}
    }
    zfclose(fp);
}
예제 #12
0
파일: mindwave.c 프로젝트: cyberpeople/mind
/**
 * Program which prints ThinkGear EEG_POWERS values to stdout.
 */
int main( void ) {

	opensocket();
	dataFile = fopen("dataStore.txt", "a+");

    /* Print driver version number */
    dllVersion = TG_GetDriverVersion();
    printf( "ThinkGear DLL version: %d\n", dllVersion );

    /* Get a connection ID handle to ThinkGear */
    connectionId = TG_GetNewConnectionId();
    if( connectionId < 0 ) {
        fprintf( stderr, "ERROR: TG_GetNewConnectionId() returned %d.\n", 
                 connectionId );
        wait();
        exit( EXIT_FAILURE );
    }

    /* Attempt to connect the connection ID handle to serial port "COM5" */
    //comPortName = "\\\\.\\COM19";
	comPortName = "COM7:";
    errCode = TG_Connect( connectionId, 
                          comPortName, 
                          TG_BAUD_57600, 
                          TG_STREAM_PACKETS );

	printf("TG_Connect struct: %d, %s, %d \n", connectionId, comPortName, TG_BAUD_57600);
    if( errCode < 0 ) {
        fprintf( stderr, "ERROR: TG_Connect() returned %d.\n", errCode );
        wait();
        exit( EXIT_FAILURE );
    }

    errCode = TG_EnableBlinkDetection( connectionId, 1 );
    if( errCode < 0 ) {
        fprintf( stderr, "ERROR: TG_EnableBlinkDetection() returned %d.\n", errCode );
        wait();
        exit( EXIT_FAILURE );
    }


	do
	{
		readdata();
		if(blink>=80)
			trncmd();
		else if(att>=68)
			fwdcmd();
		//wait();
		 
	}while(1);

    /* Clean up */
    TG_FreeConnection( connectionId );

    /* End program */
    wait();
    return( EXIT_SUCCESS );
}
예제 #13
0
파일: achk-test.c 프로젝트: LofaroLabs/ach
int selecttest(const char* ch1, const char* ch2)
{
  int fd1 = open(ch1, O_RDWR);
  if (fd1 < 0) {
    printf("Error opening %s\n", ch1);
    return -1;
  }
  int fd2 = open(ch2, O_RDWR);
  if (fd2 < 0) {
    printf("Error opening %s\n", ch2);
    close(fd1);
    return -1;
  }

  int cnt = 5;
  while (cnt) {
    fd_set readset;
    FD_ZERO(&readset);
    FD_SET(fd1, &readset);
    FD_SET(fd2, &readset);
    struct timeval tv;
    tv.tv_sec = 5;
    tv.tv_usec = 0;
    int res = select(fd2+1, &readset, NULL, NULL, &tv);
    if (res == 0) {
      printf("select timed out\n");
    }
    if (res > 0) {
      cnt--;
      if (FD_ISSET(fd1, &readset)) {
        readdata(fd1, 0);
      }
      if (FD_ISSET(fd2, &readset)) {
        readdata(fd2, 0);
      }
    }
  }
 out:
  close(fd1);
  close(fd2);

  return 0;
}
예제 #14
0
static void getdata (PIC_PARM *pp)
{
	//reads more data into the Get queue
	//As written, this routine FILLs the Get queue.
	//This is not necessary; you can put in as much or as little as you like
	// each time.

	long ndo, ix;
	QUEUE *q;

	q = &pp->Get;
	if (total_bytes_read >= infilesize - seek_adder)
	{
		//the opcode requested too much data
		printf ("***** getdata -- attempt to read past end of file\n");
		fail (pp, 1);
	}
	ndo = bytes_free_in_queue (q);
	if (ndo <= 0)
	{
		return;	//presumably a yield call
	}
	ndo = min (ndo, infilesize - seek_adder - total_bytes_read);
	if (ndo + q->Rear <= q->End)
	{
		//all at once
		readdata (q->Rear, ndo, pp);
		q->Rear += ndo;
		if (q->Rear >= q->End)
		{
			q->Rear = q->Start;
		}
	}
	else
	{
		//in 2 chunks
		readdata (q->Rear, ix = (q->End - q->Rear), pp);
		readdata (q->Start, ix = (ndo - ix), pp);
		q->Rear = q->Start + ix;
	}
	total_bytes_read += ndo;
}
예제 #15
0
int main()
{
    const char *query_string = getenv("QUERY_STRING");
    if (query_string == NULL) {
        generatepage("Internal error: invalid request");
        return EXIT_SUCCESS;
    }

    if (NULL != validate_name_version(query_string)) {
        generatepage(validate_name_version(query_string));
        return EXIT_SUCCESS;
    }

    char *data[MAX_RECORDS] = {0};
    if (!readdata(data, MAX_RECORDS)) {
        generatepage("Failed to delete file, try again");
        return EXIT_SUCCESS;
    }
    sortdata(data, MAX_RECORDS);

    char name[MAX_NAME_LEN] = {0};
    strcpy(name, getname(query_string));
    int index = -1;
    for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
        if (strcmp(name, getname(data[i])) == 0) {
            index = i;
            break;
        }
    }

    if (index == -1) {
        generatepage("File not found");
        return EXIT_SUCCESS;
    }

    FILE *f = fopen("data.txt", "wt");
    if (f == NULL) {
        generatepage("Failed to delete file (access denied)");
        return EXIT_SUCCESS;
    }

    int deleted = 0;
    for (int i = 0; i < MAX_RECORDS && data[i]; i++) {
        if (i != index)
            fprintf(f, "%s\n", data[i]);
        else
            deleted = 1;
    }
    fclose(f);

    generatepage(deleted ? "File deleted" : "Failed to delete file");

    return EXIT_SUCCESS;
}
예제 #16
0
파일: Gyro.cpp 프로젝트: Tenpura/tanitan2
bool Gyro::whoami(){
	std::vector<uint8_t> writedata(1);
	std::vector<uint8_t> readdata(1);
	writedata[0] = static_cast<uint8_t>(GyroCommands::WHO_AM_I) | 0x80;
	readdata[0] = 0x00;
	auto retval = rwMultiByte(readdata, writedata, 1, 1);
	if(retval) return false;
	retval = configAutomatic();
	if(retval) return false;
	if(readdata[0] == 0x69) return true;
	else return false;
}
예제 #17
0
파일: Gyro.cpp 프로젝트: Tenpura/tanitan2
uint16_t Gyro::readAccelY(){
	uint16_t ret = 0x0000;
	std::vector<uint8_t> writedata(1);
	std::vector<uint8_t> readdata(1);
	writedata[0] = static_cast<uint8_t>(GyroCommands::OUTY_H_XL) | 0x80;
	rwMultiByte(readdata, writedata, 1, 1);
	ret += (static_cast<uint16_t>(readdata[0]) << 8);
	writedata[0] = static_cast<uint8_t>(GyroCommands::OUTY_L_XL) | 0x80;
	rwMultiByte(readdata, writedata, 1, 1);
	ret += readdata[0];
	return ret;
}
예제 #18
0
파일: Gyro.cpp 프로젝트: Tenpura/tanitan2
bool Gyro::configAutomatic(){
	uint8_t ret = 0;
	std::vector<uint8_t> writedata(2);
	std::vector<uint8_t> readdata(1);
	writedata[0] = static_cast<uint8_t>(GyroCommands::CTRL2_G);
	writedata[1] = 0x8C;
	ret = rwMultiByte(readdata, writedata, 0, 2);
	writedata[0] = static_cast<uint8_t>(GyroCommands::CTRL1_XL);
	writedata[1] = 0x70;
	ret = rwMultiByte(readdata, writedata, 0, 2);
	return ret;
}
예제 #19
0
bool DVR::login(const string& username, const string& pass)
{
	TDVRPacket pk;
	int res;
	
	char user_pass[20];
	sprintf(user_pass, "%s&&%s", username.c_str(), pass.c_str());
	
	strncpy((char*)&pk.raw[8], username.c_str(), 8);
	strncpy((char*)&pk.raw[16], pass.c_str(), 8);
	
	pk.setCmd(0xa0);
	//pk.raw[3] = 0x60;
	pk.raw[24] = 0x04;
	pk.raw[25] = 0x01;
	//pk.raw[30] = 0xa1;
	//pk.raw[31] = 0xaa;
	//pk.setExtLen (strlen (user_pass));
	
	res = senddata(m_controlFd, pk.raw, 32);
	if (res == -1)
	{
		setError(ConnectionError, getErrorText("unable to send login request packet"));
		return false;
	}	
	res = readdata(m_controlFd, pk.raw, 32);
	if (res == -1)
	{
		setError(ConnectionError, getErrorText("unable to read login response packet"));
		return false;
	}
	
	if (pk.getCmd() != 0xb0)
	{
		setError(ConnectionError, "invalid login response");
		return false;
	}
	
	res = pk.raw[8];
	if (res != 0)
	{
		int code = pk.raw[9];
		char buf[200];
		sprintf(buf, "channel request error - res: %d code: %d", res, code);
		setError(LoginError, buf);
		return false;
	}
	
	m_connId = *(uint32_t*)(pk.raw + 16);

	return true;
}
예제 #20
0
파일: election.c 프로젝트: avitase/uninf
int main(int argc, char **argv) {
	if(argc!= 1+R*P) return EXIT_FAILURE;

	int a[R][P], *ap[R], i;
	for(i=0; i<R; i++) ap[i]=a[i];
	readdata(argv, ap);

	int p[P];
	sumcolumn(ap, p);

	print(p);

	return EXIT_FAILURE;
}
예제 #21
0
파일: read.c 프로젝트: aahud/harvey
Proc*
readsnap(Biobuf *b)
{
	char *q;
	char buf[12];
	int32_t pid;
	Proc *p, *plist;
	int i, n;

	if((q = Brdline(b, '\n')) == nil)
		panic("error reading snapshot file");
	if(strncmp(q, "process snapshot", strlen("process snapshot")) != 0)
		panic("bad snapshot file format");

	plist = nil;
	while(q = Brdline(b, '\n')) {
		q[Blinelen(b)-1] = 0;
		pid = atol(q);
		q += 12;
		p = findpid(plist, pid);
		if(p == nil) {
			p = emalloc(sizeof(*p));
			p->link = plist;
			p->pid = pid;
			plist = p;
		}

		for(i=0; i<Npfile; i++) {
			if(strcmp(pfile[i], q) == 0) {
				p->d[i] = readdata(b);
				break;
			}
		}
		if(i != Npfile)
			continue;
		if(strcmp(q, "mem") == 0) {
			if(Bread(b, buf, 12) != 12) 
				panic("can't read memory section");
			n = atoi(buf);
			p->nseg = n;
			p->seg = emalloc(n*sizeof(*p->seg));
			for(i=0; i<n; i++)
				readseg(&p->seg[i], b, plist);
		} else if(strcmp(q, "text") == 0)
			readseg(&p->text, b, plist);
		else
			panic("unknown section");
	}
	return plist;
}
예제 #22
0
파일: main.c 프로젝트: murachue/WING
int main(int argc, char *argv[])
{
	glutInit(&argc, argv);
	options(argc, argv);

	if (mapmode) {
	/* read map data */
		readDigitalMap(MAPDIR "nara.map");
		readMeshData(MAPDIR "nara.mem");
		calcAllAltitude();
	}

	mapwindow = openMapWindow(argv[0]);	/* initialize 3D map window */

	/* 970904 イベントハンドラの設定 */
	glutDisplayFunc(drawScene);
	glutKeyboardFunc(mapKeyFunc);
	glutSpecialFunc(mapSpecialFunc);	/* 特殊キー用 */
	glutMouseFunc(mapMouseFunc);
	glutMotionFunc(mapMotionFunc);

	readdata();			/* read guide data */
	initGuide();			/* initialize the guide */
	initIndex();			/* initialize the index */
	initTOC();			/* initialize the TOC */

/* prepare graphics objects */
	setPartNVec(&compass);
	setPartNVec(&pencursor);

/* texture */
	/* 970904 あとで参考にするかもしれない
	if (!wiremode && !mapmode && texturemode) {
		tevdef(1, 0, tevprops[0]);
		tevbind(TV_ENV0, 1);
		if ((tid = readTexture(texturename, texturemode - 1)) == 0) {
			perror("cannot read texture data\n");
			exit(0);
		}
		texbind(TX_TEXTURE_0, tid);
	}
	*/

	calcLookAtPoint(lookAt, FALSE);
	glutSetWindow(mapwindow);
	glutPostRedisplay();

/* main loop */
	glutMainLoop();
}
예제 #23
0
파일: name_afqt.cpp 프로젝트: code-cg/cgru
bool afqt::recvMessage( QTcpSocket * qSocket, af::Msg * msg)
{
	char * buffer = msg->buffer();
	int bytes = readdata( qSocket, buffer, af::Msg::SizeHeader, af::Msg::SizeBuffer);
	if( bytes < af::Msg::SizeHeader)
	{
		AFERROR("qtcom::recvMessage: read message header.\n");
		return false;
	}

//	msg->readHeader( bytes);
	// Header offset is variable on not binary header (for example HTTP)
	int header_offset = af::processHeader( msg, bytes);
	if( header_offset < 0)
		return false;

	if( msg->type() >= af::Msg::TDATA)
	{
		buffer = msg->buffer(); // buffer may be changed to fit new size
		bytes -= header_offset;
//		int readlen = msg->dataLen() - bytes + af::Msg::SizeHeader;
		int readlen = msg->dataLen() - bytes;
		if( readlen > 0)
		{
			//bytes = readdata( qSocket, buffer+bytes, readlen, readlen);
			bytes = readdata( qSocket, buffer + af::Msg::SizeHeader + bytes, readlen, readlen);
			//bytes = ::readdata( desc, buffer + af::Msg::SizeHeader + bytes, readlen, readlen);
			if( bytes < readlen)
			{
				AFERROR("qtcom::recvMessage: read message data.\n");
				msg->setInvalid();
				return false;
			}
		}
	}
	return true;
}
예제 #24
0
bool DVR::removeChannel(int channel)
{
	TDVRPacket pk;
	int res;
	TStreamConnection *strm = 0;
	
	for (size_t i = 0; !strm && i < m_conns.size(); i++)
		if (m_conns[i].channel == channel)
			strm = &m_conns[i];
	if (!strm) return false;
	
	pk.setCmd(0xf1);
	pk.setU32(8, m_connId);
	pk.raw[12] = 1;
	pk.raw[13] = channel + 1;
	pk.raw[17] = 1; // 0-estabilish, 1-close
	
	res = senddata(strm->fd, pk.raw, 32);
	if (res == -1)
	{
		setError(ConnectionError, getErrorText("unable to send conn unbind request packet"));
		return false;
	}
	res = readdata(strm->fd, pk.raw, 32);
	if (res == -1)
	{
		setError(ConnectionError, getErrorText("unable to read conn unbind response packet"));
		return false;
	}
	
	res = pk.raw[14];
	if (res != 0)
	{
		int code = pk.raw[8];
		char buf[200];
		sprintf(buf, "channel request error - res: %d code: %d", res, code);
		setError(LoginError, buf);
		return false;
	}
	
	close(strm->fd);
	
	delete [] strm->buffer;
	for (size_t i = 0; i < m_conns.size(); i++)
		if (m_conns[i].channel == channel)
			m_conns.erase(m_conns.begin() + i);
			
	return true;
}
예제 #25
0
/**
 * Read an arbitrary amount of data.
 * @param location Location to read from.
 * @param length   Amount of bytes to read.
 * @return         Data read.
 */
std::vector<byte> SerialInterface::read_data(address location, size_t length)
{
    if (!request(location) || !send_command(0xA1))
        return std::vector<byte>(); // TODO: error?

    std::vector<byte> readdata(length);
    readdata[0] = read_byte();
    for (size_t i = 1; i < length; i++) {
        request_next();
        readdata[i] = read_byte();
    }
    end_command();

    return readdata;
}
예제 #26
0
파일: achk-test.c 프로젝트: LofaroLabs/ach
int getalldata(const char* channel)
{
  int res = 0;
  printf ("Getting all unread data\n");
  int fd = open(channel, O_RDWR);
  if (fd < 0) {
    printf ("Error opening %s\n", channel);
    return -1;
  }
  unsigned int flag = 0; /* Get old */
  while (!res) {
    res = readdata(fd, flag);
  }

  close(fd);
  return 0;
}
예제 #27
0
파일: achk-test.c 프로젝트: LofaroLabs/ach
int getwithwait(const char* channel)
{
  int res = 0;
  printf ("Getting all unread data\n");
  int fd = open(channel, O_RDWR);
  if (fd < 0) {
    printf ("Error opening %s\n", channel);
    return -1;
  }
  unsigned int flag = ACH_CH_MODE_LAST | ACH_CH_MODE_WAIT;
  while (!res) {
    res = readdata(fd, flag);
  }

  close(fd);
  return 0;
}
예제 #28
0
파일: achk-test.c 프로젝트: LofaroLabs/ach
int getnewdata(const char* channel)
{
  int res = 0;
  printf("Getting newest data\n");
  int fd = open(channel, O_RDWR);
  if (fd < 0) {
    printf ("Error opening %s\n", channel);
    return -1;
  }

  unsigned int flag = ACH_CH_MODE_LAST;

  res = readdata(fd, flag);

 out:
  close(fd);
  return res;
}
예제 #29
0
void eeprom_read()
{
	/***********************WRITING DATA*************************************/
	start();
	uart_tx_str("\r\nhere\r\n");
	devadd1();
	location(0x00);
	stop();
	
	/******************************************READ********************************************/
	start();
	devadd2();
	for(j=0;j<=5;j++)
	{
		uart_tx_char(readdata());
	}

	stop();
}
예제 #30
0
PICTURE *readpic(char *filename)
{
PICTURE *pic = newpic();
FILE *fp;

if (filename == NULL) { filename = (char *)"stdin"; fp = stdin; }
else
	if ((fp = fopen(filename,"rb")) == NULL )
		{
		(void)fprintf(stderr,"%s: readpic: failed to open input file %s\n",
		PROGNAME,filename);
		return(NULL);
		}
(void)fprintf(stderr,"Reading %s from disk: ",filename);
if ((readhead(pic,fp)) == -1) return(NULL);
if (readdata(pic,fp)) return(NULL);
fclose(fp);
return(pic); 
}