⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 receivedatagramv2.3.c~

📁 这是一个进程通信和手机数据处理程序, 与以前发的手机界面一起构成一个简单手机系统,是我们做的第一个版本,供大家一起学习
💻 C~
📖 第 1 页 / 共 3 页
字号:
						newData->dwxx->abnormalHeigtht = DataGram[29];
					}
					else
					{
						newData->dwxx->height = (long) DataGram[26]*mid*mid + DataGram[27]*mid + DataGram[28];
					}					/* write the data to the shared memory */										CheckTidCount( );					printf("-------Initial Address DWXX of  newData->dwxx is %lX.-------\n",newData->dwxx);					printf("-------Initial Address DWXX of  newData  is %lX.-------\n",newData);					newData->currentMesg = TYPE_OF_DWXX;					newData->myshmPtr = ptr;					//Set_concurrency( tidcount + 1 );      					Pthread_create(&tid_Produce[tidcount],&attr,Produce,(void *)newData);															printf("tidcount is %d\n",tidcount);

					break;

				case 'T':
										newData = (NEWDATA *)malloc(sizeof( NEWDATA ));					newData->txxx = (TXXX *)malloc(sizeof( TXXX ));
					/**Handle the information of remoting communication.**/

					/* Obtain the id of the source user. */
					firstByte=  DataGram[7];
					secondByte= DataGram[8];
					thirdByte =  DataGram[9];
					newData->txxx->srcID= (long) firstByte*mid*mid + secondByte*mid + thirdByte;

					printf("SRCID is =%lX\n",newData->txxx->srcID);

					/* Obtain the Charcter type of received  message.*/
					if( ( newData->txxx->chType = (DataGram[10] & 0x20)) == 0)
						printf("Chinese.\n");
					else
						printf("Binary.\n");

					/* Obtain the mode of communication */
					if( ( newData->txxx->commType = DataGram[10] & 0x08) == 0)
						printf("The type is communication.\n");
					else
						printf("The type is inquery.\n");

					/* Obtain the secretkey */
					if( ( newData->txxx->isSecretKey = DataGram[10] & 0x04) == 0)
						printf("Not been encrypted.\n");
					else
						printf("Has been encrypted.\n");

					/* Obtain the id of destination user.*/
					firstByte =  DataGram[11];
					secondByte = DataGram[12];
					thirdByte =  DataGram[13];
					newData->txxx->srcID = (long)firstByte*mid*mid+secondByte*mid+thirdByte;

					printf("SRCID is =%lX\n",newData->txxx->srcID);

					/* Obtain the time */
					newData->txxx->hour = DataGram[14];
					newData->txxx->minute = DataGram[15];
					printf(" The time of sending message is:%d,%d\n",newData->txxx->hour,newData->txxx->minute);

					/* Obtain the length of data Content.*/
					firstByte=  DataGram[16];
					secondByte= DataGram[17];
					newData->txxx->contentLen = (long) firstByte*mid + secondByte;

					printf("ContentLen is =%lX\n",newData->txxx->contentLen);


					/* Obtain the actual data of the datagram.*/
					j=18;
					for( i=0;i<newData->txxx->contentLen;i++ )
					{
						(newData->txxx->message)[i]=DataGram[j++];
					}

					/*Test for CN Character Graph.
					initgraph(&gdrive,&gmode,"");

					if((fp=fopen("hzk16","rb"))==NULL)
					{
						printf("cannot open file\n");
						exit(0);
					}
					WriteHzStr( txxx->ContentLen );

					fclose(fp);
					getch();
					closegraph();*/

					/* Obtain the CRC sign */
					newData->txxx->CRC_Sign = DataGram[ DataLen - 2 ];
					if( newData->txxx->CRC_Sign == 0x00 )
						printf("Correct CRC sign!");
					else if( newData->txxx->CRC_Sign == 0x01 )
						printf("Incorrect CRC sign!");					CheckTidCount( );										printf("-------Initial Address TXXX of  newData->txxx is %lX.-------\n",newData->txxx);					printf("-------Initial Address TXXX of  newData is %lX.-------\n",newData);					newData->currentMesg = TYPE_OF_TXXX;					newData->myshmPtr = ptr;					//Set_concurrency( tidcount + 1 );      					Pthread_create(&tid_Produce[tidcount],&attr,Produce,(void *)newData);					printf("tidcount is %d\n",tidcount);

					break;


				case 'I':										newData = (NEWDATA *)malloc(sizeof( NEWDATA ));					newData->icxx = (ICXX *)malloc(sizeof( ICXX ));
					/**Handle the information on IC card **/

					/* Obtain the id of the source user. */
					firstByte=  DataGram[7];
					secondByte= DataGram[8];
					thirdByte=  DataGram[9];
					newData->icxx->srcID= (long) firstByte*mid*mid + secondByte*mid + thirdByte;

					printf("SRCID is =%lX\n",newData->icxx->srcID);

					/* Obtain the current frame from the message*/
					newData->icxx->frame = DataGram[10];

					printf("Current frame is =%d\n",newData->icxx->frame);

					/* Obtain the BroadcastID */
					firstByte=  DataGram[11];
					secondByte= DataGram[12];
					thirdByte=  DataGram[13];
					newData->icxx->broadcastID = (long) firstByte*mid*mid + secondByte*mid + thirdByte;

					printf("BroadcastID is =%lX\n",newData->icxx->broadcastID);

					/* Obtain the UserCharacter */
					newData->icxx->userCharacter= DataGram[14];

					printf("UserCharacter is =%d\n",newData->icxx->userCharacter);

					/* Obtain the  ServFrequency*/
					firstByte=  DataGram[15];
					secondByte= DataGram[16];
					newData->icxx->servFrequency = (long) firstByte*mid + secondByte;

					printf("ServFrequency is =%d\n",newData->icxx->servFrequency);

					/* Obtain the rank of communication*/
					newData->icxx->commRank = DataGram[17];
					
					if( newData->icxx->commRank>=0 && newData->icxx->commRank<=4)
					printf("The rank of communication is :%d \n",newData->icxx->commRank);

					/* Obtain the need to encrypt */
					newData->icxx->encryptSign = DataGram[18];
					if( newData->icxx->encryptSign == 1)
						printf("It is encrypted user.\n");
					else
						printf("It is not encrypted user.\n");

					/* Obtain the number of underling user*/
					/**/firstByte=  DataGram[19];
					secondByte= DataGram[20];
					newData->icxx->underlingNum = (long) firstByte*mid + secondByte;

					printf("underlingNum is =%lX\n",newData->icxx->underlingNum);					CheckTidCount( );					newData->currentMesg = TYPE_OF_ICXX;					newData->myshmPtr = ptr;					//Set_concurrency( tidcount + 1 );      					Pthread_create(&tid_Produce[tidcount],&attr,Produce,(void *)newData);						printf("tidcount is %d\n",tidcount);


					break;

				case 'Z':					newData = (NEWDATA *)malloc(sizeof( NEWDATA ));					newData->zjxx = (ZJXX *)malloc(sizeof( ZJXX ));
					/**Handle the information of SelfChecking**/

					/* Obtain the id of the source user. */
					firstByte=  DataGram[7];
					secondByte= DataGram[8];
					thirdByte=  DataGram[9];
					newData->zjxx->srcID= (long) firstByte*mid*mid + secondByte*mid + thirdByte;

					printf("SRCID is =%lX\n",newData->zjxx->srcID);

					/* Obtain the status of IC card*/
					newData->zjxx->icStat= DataGram[10];

					if( newData->zjxx->icStat != 0)
						printf("Error occured in IC card!\n");

					/* Obtain the status of Hardware*/
					newData->zjxx->hardWareStat= DataGram[11];

					if( newData->zjxx->hardWareStat != 0)
						printf("Error occured in HardwareStat!\n");

					/* Obtain the status of electricity quantity*/
					newData->zjxx->elecQuantity= 1.0 / DataGram[12];
					printf("The current electricity quantity is taken up %f.\n",newData->zjxx->elecQuantity);

					/* Obtain the status of enter*/
					newData->zjxx->enterStat= DataGram[13];

					if( newData->zjxx->enterStat == 1)
						printf("Permit to enter in but restrain it!\n");
					else if( newData->zjxx->enterStat == 0)
						printf("Can't enter in without restriction!");

					/* Obtain the status of beam power*/
					newData->zjxx->fstPowerStat= DataGram[14];
					newData->zjxx->secPowerStat= DataGram[15];
					newData->zjxx->thrPowerStat= DataGram[16];
					newData->zjxx->forPowerStat= DataGram[17];
					newData->zjxx->fifPowerStat= DataGram[18];
					newData->zjxx->sixPowerStat= DataGram[19];

					printf("The power of each beam is :%X,%X,%X,%X,%X,%X\n",newData->zjxx->fstPowerStat,newData->zjxx->secPowerStat,newData->zjxx->thrPowerStat,newData->zjxx->forPowerStat,newData->zjxx->fifPowerStat,newData->zjxx->sixPowerStat);					CheckTidCount( );					newData->currentMesg = TYPE_OF_ZJXX;					newData->myshmPtr = ptr;					//Set_concurrency( tidcount + 1 );      					Pthread_create(&tid_Produce[tidcount],&attr,Produce,(void *)newData);						/* wait for the Producers 					Pthread_join(tid_Produce[tidcount], NULL);					tidcount--; */					printf("tidcount is %d\n",tidcount);

					break;

				case 'S':					newData = (NEWDATA *)malloc(sizeof( NEWDATA ));					newData->sjxx = (SJXX *)malloc(sizeof( SJXX ));
					/**Handle the information of BD timer**/

					/* Obtain the id of the source user. */
					firstByte=  DataGram[7];
					secondByte= DataGram[8];
					thirdByte=  DataGram[9];
					newData->sjxx->srcID= (long) firstByte*mid*mid + secondByte*mid + thirdByte;

					printf("srcID is =%lX\n",newData->sjxx->srcID);

					/* Obtain the current precise time */
					firstByte =  DataGram[10];
					secondByte = DataGram[11];
					newData->sjxx->sj.year = firstByte*mid + secondByte;

					newData->sjxx->sj.mon = DataGram[12];
					newData->sjxx->sj.mday = DataGram[13];
					newData->sjxx->sj.hour = DataGram[14];
					newData->sjxx->sj.min = DataGram[15];
					newData->sjxx->sj.sec = DataGram[16];

					printf("The current time is:%ld.%d.%d %d:%d:%d \n",newData->sjxx->sj.year,newData->sjxx->sj.mon,newData->sjxx->sj.mday,newData->sjxx->sj.hour,newData->sjxx->sj.min,newData->sjxx->sj.sec);					CheckTidCount( );					newData->currentMesg = TYPE_OF_SJXX;					newData->myshmPtr = ptr;					//Set_concurrency( tidcount + 1 );      					Pthread_create(&tid_Produce[tidcount],&attr,Produce,(void *)newData);						/* wait for the Producers 					Pthread_join(tid_Produce[tidcount], NULL);					tidcount--;*/					printf("tidcount is %d\n",tidcount);


					break; 
				case 'B':					newData = (NEWDATA *)malloc(sizeof( NEWDATA ));					newData->bbxx = (BBXX *)malloc(sizeof( BBXX ));
					/**Handle the information of current version**/

					firstByte=  DataGram[7];
					secondByte= DataGram[8];
					thirdByte=  DataGram[9];
					newData->bbxx->srcID= (long) firstByte*mid*mid + secondByte*mid + thirdByte;

					printf("srcID is =%lX\n",newData->bbxx->srcID);

					j=10;
					for( i=0;i<DataLen-11;i++ )
					{
						newData->bbxx->verInfor[i]=DataGram[j++];
					}					CheckTidCount( );					newData->currentMesg = TYPE_OF_BBXX;					newData->myshmPtr = ptr;					//Set_concurrency( tidcount + 1 );      					Pthread_create(&tid_Produce[tidcount],&attr,Produce,(void *)newData);						/* 					tidcount--;*/					printf("tidcount is %d\n",tidcount);

					break;

				case 'F':					newData = (NEWDATA *)malloc(sizeof( NEWDATA ));					newData->fkxx = (FKXX *)malloc(sizeof( FKXX ));
					/**Handle the information of feedback**/

					firstByte=  DataGram[7];
					secondByte= DataGram[8];
					thirdByte=  DataGram[9];
					newData->fkxx->srcID= (long) firstByte*mid*mid + secondByte*mid + thirdByte;

					printf("SRCID is =%lX\n",newData->fkxx->srcID);

					newData->fkxx->FeedBackSign = DataGram[10];
					switch( newData->fkxx->FeedBackSign )
					{
					case 0x00:

						printf("Sign for Success!\n");
						j= 11;
						for( i=0; i<4; i++)
						{
							(newData->fkxx->AdditionalINfor)[i]= DataGram[j++];
							printf("%c ",(newData->fkxx->AdditionalINfor)[i]);
						}
						printf("\n");
						break;

					case 0x01:

						j= 11;
						printf("Sign for Failure!\n");
						for( i=0; i<4; i++)
						{
							(newData->fkxx->AdditionalINfor)[i]= DataGram[j++];
							printf("%c ",(newData->fkxx->AdditionalINfor)[i]);
						}
						printf("\n");
						break;

					case 0x02:

						printf("Signal unlocked!\n");
						break;

					case 0x03:

						printf("Low battery power!\n");

						break;

					case 0x04:

						printf("Need to wait to send data!\n");
						(newData->fkxx->AdditionalINfor[0]) = DataGram[11];
						printf("%c ",(newData->fkxx->AdditionalINfor)[0]);

						break;

					case 0x05:

						printf("Error occurred during the process of encryption or Cracking code!\n");

						break;

					case 0x06:

						j= 11;
						printf("CRC error!\n");
						for( i=0; i<4; i++)
						{
							(newData->fkxx->AdditionalINfor)[i]= DataGram[j++];
							printf("%c ",(newData->fkxx->AdditionalINfor)[i]);
						}
						printf("\n");
						break;					

					/* The values of  feedback's sign from 0x09 to 0xA0 are  reserved*/
					/* and the values from 0xA1 to 0xFF have been reserved to be the */
					/* extension   of   the   corporation   at   this   time .       */
					}					if( tidcount+1 > MAXNTHREADS)						tidcount = 0;					else						tidcount++;					newData->currentMesg = TYPE_OF_FKXX;					newData->myshmPtr = ptr;					//Set_concurrency( tidcount + 1 );      					Pthread_create(&tid_Produce[tidcount],&attr,Produce,(void *)newData);						printf("tidcount is %d\n",tidcount);

					break;

				}
				printf("Reflush previous rightly checkSum : %X  \n",checkSum);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -