]> rtime.felk.cvut.cz Git - mf6xx.git/commitdiff
Passing port number to Qt interface as commandline argument now works.
authorRostislav Lisovy <lisovy@gmail.com>
Sun, 10 Apr 2011 18:03:14 +0000 (20:03 +0200)
committerRostislav Lisovy <lisovy@gmail.com>
Sun, 10 Apr 2011 18:03:14 +0000 (20:03 +0200)
src/qemu/mf624_interface/untitled/main.cpp
src/qemu/mf624_interface/untitled/mf624_io_status.h
src/qemu/mf624_interface/untitled/socket_thread.cpp

index d0cee8d3011ac187ca94be5971f1a80bc16dcaa5..739a71fdfc431d867bf55a5771b39a811c8bb745 100644 (file)
@@ -6,6 +6,12 @@ mf624_io_status_t mf624_io_status;
 
 int main(int argc, char *argv[])
 {      
+       if (argc < 2) {
+               fprintf(stderr, "Usage %s PORT\n", argv[0]);
+               ::exit(1);
+       }
+
+       mf624_io_status.portno = atoi(argv[1]);
        mf624_io_status.DIN = 0;
        mf624_io_status.DOUT = 0;
        mf624_io_status.DA0 = 0;
index 4615ae201e816f3576d694c04f24196e33b2b78a..e7aff60b98a9cbd829f46013de596c93d7ac646c 100644 (file)
@@ -3,6 +3,7 @@
 
 
 typedef struct {
+       int portno;
        unsigned int DIN;
        unsigned int DOUT;
        int DA0;
index 44246d9371040dede44cfaf8ae243b0de8fefe46..d10e8cc26d9bf7f8ad6fa06dea094996a44d5a13 100644 (file)
@@ -38,7 +38,7 @@ void socket_thread::socket_send(const char* str, int val)
 void socket_thread::run()
 {
 #define STRING_BUFF_SIZE       256
-       qDebug() << "Executing in new independant thread, GUI is NOT blocked";
+       //qDebug() << "Executing in new independant thread, GUI is NOT blocked";
 
        int portno;
        int n;
@@ -50,12 +50,7 @@ void socket_thread::run()
        int val;
        char buffer[256];
 
-       //if (argc < 3) {
-       //   fprintf(stderr,"usage %s hostname port\n", argv[0]);
-       //   exit(0);
-       //}
-       //portno = atoi(argv[2]);
-       portno = atoi("55555");
+
 
        sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
        if (sockfd < 0) {
@@ -76,9 +71,10 @@ void socket_thread::run()
             (char *)&serv_addr.sin_addr.s_addr,
             server->h_length);
 
-       serv_addr.sin_port = htons(portno);
+       serv_addr.sin_port = htons(mf624_io_status.portno);
        if (::connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
                perror("connect()");
+               ::exit(1);
        }