+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Full Member level 4
    Points: 1,951, Level: 10

    Join Date
    Jul 2014
    Posts
    223
    Helped
    14 / 14
    Points
    1,951
    Level
    10

    Run python on cyclone 5 soc

    hi,
    i have a cylone 5 sockit, which a c programming is running on arm processor generating 32 bit value at 10k rate.

    now what i wanted is to run a python inside the arm processor and implement "socket programming", so that with the help of ethernet, i can take out the live out at 10k rate to my pc.

    so i had few doubts, i had to take data from arm processor to pc, so the python should run in arm processor right or else in pc ?

    And if i wanted to run python in arm processor, do i need to build a new u_boot image ?or else can i copy the python libraries to
    the current image and run it ?

    I got the program for the "server client" internet, its relatively simple, but how can i run a python inside the arm processor is the problem now.

    Anybody got any materiel or some relative things which will help me, please share it .
    Any help is really appreciated

    thanks and regards

    •   AltAdvertisement

        
       

  2. #2
    Full Member level 4
    Points: 915, Level: 6

    Join Date
    May 2019
    Location
    Roskilde, Denmark
    Posts
    210
    Helped
    9 / 9
    Points
    915
    Level
    6

    Re: Run python on cyclone 5 soc

    Hi dipin

    Quote Originally Posted by dipin View Post
    i have a cylone 5 sockit, which a c programming is running on arm processor generating 32 bit value at 10k rate.
    now what i wanted is to run a python inside the arm processor and implement "socket programming", so that with the help of ethernet, i can take out the live out at 10k rate to my pc.
    I will assume you are running linux on your sockit and that it has a TCP/IP stack.

    In that case it's easiest to do a offline pip install of python. You can not just copy the python libs.

    If I were you I would simply make a listening socket in c on your sockit, you already have a working c compiler installed. I'm sure you can easily find a socket lib for your c compiler somewhere on the big internet. Using python in this case just adds unnecessary complexity.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  3. #3
    Full Member level 4
    Points: 1,951, Level: 10

    Join Date
    Jul 2014
    Posts
    223
    Helped
    14 / 14
    Points
    1,951
    Level
    10

    Re: Run python on cyclone 5 soc

    Hi Swend,

    Yes i am using a linux on it,

    I need to transfer data from fpga to PC at 10k, Using the listening socket using C , can i make it possible,really sorry if my question is stupid.

    And thanks for the python information.

    I will gather more information about your C suggestion.

    thanks Swend.

    regards
    dipin



    •   AltAdvertisement

        
       

  4. #4
    Full Member level 4
    Points: 915, Level: 6

    Join Date
    May 2019
    Location
    Roskilde, Denmark
    Posts
    210
    Helped
    9 / 9
    Points
    915
    Level
    6

    Re: Run python on cyclone 5 soc

    Hi dipin

    Quote Originally Posted by dipin View Post
    Hi Swend,
    I need to transfer data from fpga to PC at 10k, Using the listening socket using C , can i make it possible,really sorry if my question is stupid.
    Yes 2.56Mbps is nothing, I think you could easily reach 100Mbps even with sloppy programming on that hardware you have.

    Your question is not stupid. But the idea of Python is kind of silly though, It's easier just to add a listening socket to an existing c program than going through the hassle of installing Python on a crippled linux distro, I bet it doesn't even have the 'pip' packet manager installed, so you would also have to install that and it would probably start complaining about missing this and that, and before you know it you have spent a week just trying to install stuff.

    Quote Originally Posted by dipin View Post
    Hi Swend,
    I will gather more information about your C suggestion.
    Maybe start by checking if you already have a c socket lib on your linux, that would be very likely. So you would just need to write the listening socket.


    1 members found this post helpful.

  5. #5
    Full Member level 4
    Points: 1,951, Level: 10

    Join Date
    Jul 2014
    Posts
    223
    Helped
    14 / 14
    Points
    1,951
    Level
    10

    Re: Run python on cyclone 5 soc

    hi,
    i created the client and server programs which will send numbers continuously, and i tested it and its working fie. But there is BIG PROBLEM.
    i am barely getting a speed of 1k. actually i need around 100k. i connected the fpga to a router through ethernet cable and laptop also connected to router and then i was able to ru the program and transfer the numbers successfully.
    my server program ruing i fpga.
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <errno.h>
    #include <string.h>
    #include <sys/types.h>

    int main(void)
    {
    int listenfd = 0,connfd = 0;


    int count1=0;
    int count2=100;
    char chr_count1[50];//increase 50 if you going for more than 32 bit
    char chr_count2[50];//

    struct sockaddr_in serv_addr;

    char sendBuff[50];


    listenfd = socket(AF_INET, SOCK_STREAM, 0);
    printf("socket retrieve success\n");

    memset(&serv_addr, '0', sizeof(serv_addr));
    memset(sendBuff, '0', sizeof(sendBuff));

    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
    serv_addr.sin_port = htons(5000);

    bind(listenfd, (struct sockaddr*)&serv_addr,sizeof(serv_addr));

    if(listen(listenfd, 10) == -1){
    printf("Failed to listen\n");
    return -1;
    }
    connfd = accept(listenfd, (struct sockaddr*)NULL ,NULL); // accept awaiting request

    while(1)
    {
    count1 = count1+1;
    count2 = count2+1;
    sprintf(chr_count1, "%d\n\t",count1);
    sprintf(chr_count2, "%d\n",count2);
    strcpy(sendBuff, chr_count1);
    write(connfd, sendBuff, strlen(sendBuff));
    strcpy(sendBuff, chr_count2);
    write(connfd, sendBuff, strlen(sendBuff));

    //close(connfd);
    //sleep(1);
    }

    return 0;
    }
    and my client program running i my embedded command shell
    #include <sys/socket.h>
    #include <sys/types.h>
    #include <netinet/in.h>
    #include <netdb.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <errno.h>
    #include <arpa/inet.h>

    int main(void)
    {
    int sockfd = 0,n = 0;
    char recvBuff[50];
    struct sockaddr_in serv_addr;

    memset(recvBuff, '0' ,sizeof(recvBuff));
    if((sockfd = socket(AF_INET, SOCK_STREAM, 0))< 0)
    {
    printf("\n Error : Could not create socket \n");
    return 1;
    }

    serv_addr.sin_family = AF_INET;
    serv_addr.sin_port = htons(5000);
    serv_addr.sin_addr.s_addr = inet_addr("10.56.17.39");

    if(connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr))<0)
    {
    printf("\n Error : Connect Failed \n");
    return 1;
    }

    while(1)
    {
    n = read(sockfd, recvBuff, sizeof(recvBuff)-1);
    recvBuff[n] = 0;
    if(fputs(recvBuff, stdout) == EOF)
    {
    printf("\n Error : Fputs error");
    }
    printf("\n");
    }

    if( n < 0)
    {
    printf("\n Read Error \n");
    }

    return 0;
    }
    i experimented with client code,my read function is taking too much time which delays the while loop.
    so is there any way to speed it up. or how can i achieve the 100 k speed from current 1k speed.?
    any help is really appreciated

    regards



--[[ ]]--