Code:
while(1) {
ret = (PortRecvs(0,buff,sizeof(buff)-1,1000)<0); // r=registration is the command used in recv
if(ret<0)
{ printf("j = %d",j);
DelayMs(1000);
if(j == 12)
{ if(PortSends(0,DeviceId,sizeof(DeviceId))!=0)// working fine untill here
memset(buff,0,sizeof(buff));
while(1)
{
ret = (PortRecvs(0,buff,sizeof(buff)-1,1000)<0); // receiving number
if(ret<0) {printf("Receive Data:\n%d\n",buff);
}
for(i=48;i<60;i++)
{
printf("%c",buff[i]);
DelayMs(500);
}
im=0;
i=48;
while(im<12)
{
m2[im]=buff[i];
i++;
im++;
}
ScrCls();
printf("Reg no:\n %s",m2);// reg no is not constant keeps on fluctuating
DelayMs(2000);
break;
}
}
if(PortSends(0,"Registration Completed",22)!=0)
while(1)
{
ret = (PortRecvs(0,buff,sizeof(buff)-1,1000)<0);
if(ret<0)
{
ScrCls();
printf("Receive Fail..");
}
else
{
ScrCls();
for(i=160;i<170;i++)
{
printf("%c",buff[i]);
DelayMs(500);
}
printf("Receive Close Command :\n%s\n",buff);
DelayMs(3000);
}
break;
}
im=0;
i=160;
while(im<5)
{
m1[im]=buff[i];
i++;
im++;
}
im=0;
x=0;
while(m1[im]==command2[im])
{
im++;
x++;
}
ScrCls();
printf(" x = %d \n",x);
DelayMs(500);
while(x==1 || x==5)
{
ScrCls();
printf("Close command....");
DelayMs(500);
break;
}
}
PortClose(0);
I want to register my device using serial port communication between "visual studio c -pos machine- Java fX".
So ,
1.receive :i need to get registration command from Java fx
2.send: I am comparing length , if it is 12 then i am sending device id of length 8
3.receive : now i need to receive registration number from the java fx .i.e., ex/- 12345678:214.
4.send: if i get registration number then i am comparing , if length = 12 then i am sending registration completed of length 22.
5.receive : now , if length =22 then he validates and sends close command to me.
issue: in step 3 , registration number is not constant , it keeps on overlapping or sometimes i am not getting the data.
I searched many blogs and did my attempt, but i am not getting what the exact problem is? please explain me.
why Java fx is used for offline application?