Jump to content
OMRON Forums

jieyueduxing

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by jieyueduxing

  1. hello,dear fahmad,thanks for your help!

    Just now I tried your code and the result is the same as my previous result.

    this is the experiment

    EthCmd.RequestType = VR_DOWNLOAD;

    EthCmd.Request = VR_PMAC_GETRESPONSE;

    EthCmd.wValue = 0;

    EthCmd.wIndex = 0;

    strcpy(cCommand,"p100=30");

    EthCmd.wLength = htons((u_int16_t)strlen((const char*)cCommand));

    wcsncpy((wchar_t*)&EthCmd.bData[0],(const wchar_t *)cCommand,strlen(cCommand));

     

    printf("Attempting Get Response\n");

    send(sock,(const char *)&EthCmd,ETHERNETCMDSIZE + strlen(cCommand),0);

    recv(sock,cResponse,1400,0);

    printf("%s\n",cResponse);

    the result is the value of p100 is changed to 30,but the cResponse receive the Messy code.

    I do another experiment.now is strcpy(cCommand,"p100=30");and I expect the cResponse can receive the '30',but the actual is still Messy code.

    the conclusion is :

    the strange phenomenon is we can change the value of p100 in pmac,but we can't get the value of the p100 from the pmac.

    you know the pmacserver can finish the communication job very well through the tcp/ip.

    so I think there must be someplace I ignore to configure,but I don't know where.

     

    Error4 comes back from PMAC if you send some (erroneous) binary number on the socket. Please check your code and make sure that no such number is being transmitted to PMAC.

     

    Also look at the following sequence for correct method to connect to a socket and use the VR_PMAC_GETRESPONSE call.

     

    typedef struct tagEthernetCmd

    {

    u_int8_t RequestType;

    u_int8_t Request;

    u_int16_t wValue;

    u_int16_t wIndex;

    u_int16_t wLength;

    u_int8_t bData[1492];

    } ETHERNETCMD,*PETHERNETCMD;

     

    #define ETHERNETCMDSIZE 8

     

    #define VR_PMAC_GETRESPONSE 0xBF

    #define VR_UPLOAD 0xC0

    #define VR_DOWNLOAD 0x40

     

    int result,sock,length;

    struct sockaddr_in client;

    ETHERNETCMD EthCmd;

    char cCommand[256],cResponse[2048];

     

    printf("PMAC Ethernet communication test\n");

     

    sock = socket (PF_INET,SOCK_STREAM, 0);

    client.sin_addr.s_addr = inet_addr("192.6.94.5");

    client.sin_family = PF_INET;

    client.sin_port = htons(1025);

    length = sizeof(client);

     

    result = connect (sock,(__CONST_SOCKADDR_ARG)&client, (socklen_t)length);

    if(result ==0)

    printf("connect successful\n");

    else

    printf("connect failed with result = %d\n",result);

     

    EthCmd.RequestType = VR_DOWNLOAD;

    EthCmd.Request = VR_PMAC_GETRESPONSE;

    EthCmd.wValue = 0;

    EthCmd.wIndex = 0;

    strcpy(cCommand,"RHX$0");

    EthCmd.wLength = htons((u_int16_t)strlen((const char*)cCommand));

    strncpy(&EthCmd.bData[0],cCommand,strlen(cCommand));

     

    printf("Attempting Get Response\n");

    send(sock,&EthCmd,ETHERNETCMDSIZE + strlen(cCommand),0);

    recv(sock,cResponse,1400,0);

     

     

     

    hello!

    Now it's august 16th and I am writting my own tcp/ip socket code to run on my real system.during this process, I meet some problems which I can't work out.

     

    I make use of the VR_PMAC_GETRESPONSE explained in the ninth page of ethernet protocol.pdf to send the command string like "p100=100" to the pmac and it will set the value of the register "p100" to 100,which is good ,but then the recv function recvied the string which is "error4" from the pmac.In a word, the "send"function can send the right "string" and get the right result,but the pmac didn't response a right string,I don't know the reason.

    Another example is that the program use the "send" function to send the string "p100",but the "recv" function just gets the string"error4" rather than "100"which should be the right value of "p100" ,and i think it's strange.

    The follow is my key kode,thank you for helping me to get the right response!

    SOCKET sockClient=socket(AF_INET,SOCK_STREAM,0);

    SOCKADDR_IN addrSrv;

    addrSrv.sin_addr.S_un.S_addr=inet_addr("192.6.94.5"); addrSrv.sin_family=AF_INET;

    addrSrv.sin_port=htons(1025);

     

    connect(sockClient,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR));

     

    ETHERNETCMD EthCmd;

     

    EthCmd.RequestType=VR_DOWNLOAD; EthCmd.Request=0XBF;

    EthCmd.wValue=0;

    EthCmd.wIndex=0;

    EthCmd.wLength=htons((WORD)strlen(outstr));

     

    strncpy((char*)&EthCmd.bData[0],outstr,(WORD)strlen(outstr));

    send(sockClient,(char*)&EthCmd,ETHCMDSIZE+strlen(outstr),0);

    //send the command string to pmac and it works well

    recv(sockClient,szPMACDATA,1400,0);

    //recive the reponse relative to the send string but it doesn't work well

  2. hello,dear fahmad,thanks for your help!

    Just now I tried your code and the result is the same as my previous result.

    this is the experiment

    EthCmd.RequestType = VR_DOWNLOAD;

    EthCmd.Request = VR_PMAC_GETRESPONSE;

    EthCmd.wValue = 0;

    EthCmd.wIndex = 0;

    strcpy(cCommand,"p100=30");

    EthCmd.wLength = htons((u_int16_t)strlen((const char*)cCommand));

    wcsncpy((wchar_t*)&EthCmd.bData[0],(const wchar_t *)cCommand,strlen(cCommand));

     

    printf("Attempting Get Response\n");

    send(sock,(const char *)&EthCmd,ETHERNETCMDSIZE + strlen(cCommand),0);

    recv(sock,cResponse,1400,0);

    printf("%s\n",cResponse);

    the result is the value of p100 is changed to 30,but the cResponse receive the Messy code.

    I do another experiment.now is strcpy(cCommand,"p100=30");and I expect the cResponse can receive the '30',but the actual is still Messy code.

    the conclusion is :

    the strange phenomenon is we can change the value of p100 in pmac,but we can't get the value of the p100 from the pmac.

    you know the pmacserver can finish the communication job very well through the tcp/ip.

    so I think there must be someplace I ignore to configure,but I don't know where.

     

    Error4 comes back from PMAC if you send some (erroneous) binary number on the socket. Please check your code and make sure that no such number is being transmitted to PMAC.

     

    Also look at the following sequence for correct method to connect to a socket and use the VR_PMAC_GETRESPONSE call.

     

    typedef struct tagEthernetCmd

    {

    u_int8_t RequestType;

    u_int8_t Request;

    u_int16_t wValue;

    u_int16_t wIndex;

    u_int16_t wLength;

    u_int8_t bData[1492];

    } ETHERNETCMD,*PETHERNETCMD;

     

    #define ETHERNETCMDSIZE 8

     

    #define VR_PMAC_GETRESPONSE 0xBF

    #define VR_UPLOAD 0xC0

    #define VR_DOWNLOAD 0x40

     

    int result,sock,length;

    struct sockaddr_in client;

    ETHERNETCMD EthCmd;

    char cCommand[256],cResponse[2048];

     

    printf("PMAC Ethernet communication test\n");

     

    sock = socket (PF_INET,SOCK_STREAM, 0);

    client.sin_addr.s_addr = inet_addr("192.6.94.5");

    client.sin_family = PF_INET;

    client.sin_port = htons(1025);

    length = sizeof(client);

     

    result = connect (sock,(__CONST_SOCKADDR_ARG)&client, (socklen_t)length);

    if(result ==0)

    printf("connect successful\n");

    else

    printf("connect failed with result = %d\n",result);

     

    EthCmd.RequestType = VR_DOWNLOAD;

    EthCmd.Request = VR_PMAC_GETRESPONSE;

    EthCmd.wValue = 0;

    EthCmd.wIndex = 0;

    strcpy(cCommand,"RHX$0");

    EthCmd.wLength = htons((u_int16_t)strlen((const char*)cCommand));

    strncpy(&EthCmd.bData[0],cCommand,strlen(cCommand));

     

    printf("Attempting Get Response\n");

    send(sock,&EthCmd,ETHERNETCMDSIZE + strlen(cCommand),0);

    recv(sock,cResponse,1400,0);

     

     

     

    hello!

    Now it's august 16th and I am writting my own tcp/ip socket code to run on my real system.during this process, I meet some problems which I can't work out.

     

    I make use of the VR_PMAC_GETRESPONSE explained in the ninth page of ethernet protocol.pdf to send the command string like "p100=100" to the pmac and it will set the value of the register "p100" to 100,which is good ,but then the recv function recvied the string which is "error4" from the pmac.In a word, the "send"function can send the right "string" and get the right result,but the pmac didn't response a right string,I don't know the reason.

    Another example is that the program use the "send" function to send the string "p100",but the "recv" function just gets the string"error4" rather than "100"which should be the right value of "p100" ,and i think it's strange.

    The follow is my key kode,thank you for helping me to get the right response!

    SOCKET sockClient=socket(AF_INET,SOCK_STREAM,0);

    SOCKADDR_IN addrSrv;

    addrSrv.sin_addr.S_un.S_addr=inet_addr("192.6.94.5"); addrSrv.sin_family=AF_INET;

    addrSrv.sin_port=htons(1025);

     

    connect(sockClient,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR));

     

    ETHERNETCMD EthCmd;

     

    EthCmd.RequestType=VR_DOWNLOAD; EthCmd.Request=0XBF;

    EthCmd.wValue=0;

    EthCmd.wIndex=0;

    EthCmd.wLength=htons((WORD)strlen(outstr));

     

    strncpy((char*)&EthCmd.bData[0],outstr,(WORD)strlen(outstr));

    send(sockClient,(char*)&EthCmd,ETHCMDSIZE+strlen(outstr),0);

    //send the command string to pmac and it works well

    recv(sockClient,szPMACDATA,1400,0);

    //recive the reponse relative to the send string but it doesn't work well

  3. hello!

    Now it's august 16th and I am writting my own tcp/ip socket code to run on my real system.during this process, I meet some problems which I can't work out.

     

    I make use of the VR_PMAC_GETRESPONSE explained in the ninth page of ethernet protocol.pdf to send the command string like "p100=100" to the pmac and it will set the value of the register "p100" to 100,which is good ,but then the recv function recvied the string which is "error4" from the pmac.In a word, the "send"function can send the right "string" and get the right result,but the pmac didn't response a right string,I don't know the reason.

    Another example is that the program use the "send" function to send the string "p100",but the "recv" function just gets the string"error4" rather than "100"which should be the right value of "p100" ,and i think it's strange.

    The follow is my key kode,thank you for helping me to get the right response!

    SOCKET sockClient=socket(AF_INET,SOCK_STREAM,0);

    SOCKADDR_IN addrSrv;

    addrSrv.sin_addr.S_un.S_addr=inet_addr("192.6.94.5"); addrSrv.sin_family=AF_INET;

    addrSrv.sin_port=htons(1025);

     

    connect(sockClient,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR));

     

    ETHERNETCMD EthCmd;

     

    EthCmd.RequestType=VR_DOWNLOAD; EthCmd.Request=0XBF;

    EthCmd.wValue=0;

    EthCmd.wIndex=0;

    EthCmd.wLength=htons((WORD)strlen(outstr));

     

    strncpy((char*)&EthCmd.bData[0],outstr,(WORD)strlen(outstr));

    send(sockClient,(char*)&EthCmd,ETHCMDSIZE+strlen(outstr),0);

    //send the command string to pmac and it works well

    recv(sockClient,szPMACDATA,1400,0);

    //recive the reponse relative to the send string but it doesn't work well

  4. hello!Now we are taking use of the Clipper(Turbo PMAC2 Eth-Lite) as our controller and we want to write a host communication program used in IntervalZero’s RTX Real-time Platform to decrease the communiction time between the host PC and the PMAC.We had test the time the funtion GetResponseEx() takes in the Visual Studio which is about 15ms,and we want to decrease it to 1ms,so we want to write a new communication program which runs on the real time platform,but I don't know if the Delta Tau allow us to do this .If Delta Taua allows,could you please tell me how to finis it.

    thank you! Expect your answer.

    My email is 944754284@qq.com

×
×
  • Create New...