Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - virus989898

Pages: [1]
1
Network / Re: Socket.send fails on Windows
« on: August 15, 2014, 03:06:41 pm »
OK, I figured out that localhost is not working on Win8.1, so I put 127.0.0.1 instead.

SOLVED!

2
Network / Socket.send fails on Windows
« on: August 15, 2014, 02:06:44 pm »
Hi,
I finished program for controlling my quadcopter for linux machine and it works.
#include <SFML/Network.hpp>
#include <SFML/Window.hpp>
#include <iostream>

sf::UdpSocket socket;

sf::Packet paczka;
int id = 1; // 1 -> pc, 2 -> dron

sf::IpAddress odbiorca = "localhost";
unsigned short port = 54321;

#define rcthr z
#define roll x
#define pitch y
#define yaw r
#define high v

int old_roll = 0;
int old_rcthr = 0;
int old_pitch = 0;
int old_yaw = 0;
int old_high = 0;

void wypisywanie(int x, int y, int z, int r)
{
        std::cout << "\nroll(x): " << x << "  pitch(y): " << y << "  rcthr(z): " << z << "  yaw(r): " << r;
}



void push() {
        if (socket.send(paczka, odbiorca, port) != sf::Socket::Done)
        {
                std::cout << "ERROR\n";
        }
}

int main()
{
        int sygnal = 2;
        //odbiorca = "localhost";
        sf::Joystick::update();
        int button = sf::Joystick::getButtonCount(0);
        std::cout << "znalazlem" << button << "przyciskow";
        while (true)
        {
                sf::Joystick::update();

                int roll = sf::Joystick::getAxisPosition(0, sf::Joystick::X);
                int pitch = sf::Joystick::getAxisPosition(0, sf::Joystick::Y);
                int rcthr = sf::Joystick::getAxisPosition(0, sf::Joystick::Z);
                int yaw = sf::Joystick::getAxisPosition(0, sf::Joystick::R);
                int high = sf::Joystick::getAxisPosition(0, sf::Joystick::PovY);
                yaw *= -1;
                rcthr *= -1;
                rcthr += 100;
                //    wypisywanie(roll,pitch, rcthr, yaw, high);

                //      if ( (roll != old_roll) or (pitch != old_pitch) or (rcthr != old_rcthr) or (yaw != old_yaw) or (high != old_high)  ) {

                wypisywanie(roll, pitch, rcthr, yaw);
                paczka.clear();
                paczka << sygnal << id << roll << pitch << rcthr << yaw;
                push();

                sf::Time t = sf::seconds(0.05f);
                sf::sleep(t);  
                //      }


        }
        //std::cout << sf::Joystick::Count;


        return 0;
}
 
But when I tried to compile it on Windows machine I allways get ERROR after every end of line printed by "push" function. I dont know if there is a problem with my Visual Studio 2013 configuration or Windows 8 safty stuff (I've got Windows firewall and antivirus off). Do You get the same error with this code?

Thanks in advance!

3
General / Re: Illegal instruction on Raspberry Pi
« on: July 07, 2014, 06:48:53 pm »
Yup, everything's fine now. Just had to add path to .so files while executing.

4
General / Re: Illegal instruction on Raspberry Pi
« on: July 06, 2014, 06:19:17 pm »
I replaced "./programname" with "export LD_LIBRARY_PATH=/usr/local/lib && ./programname" and it looks like it is working. I'll setup whole network and share with my resault.
I think that /usr/local/lib is the default directory. Am I wrong or is because of Raspbian?

5
General / Illegal instruction on Raspberry Pi
« on: July 06, 2014, 03:37:03 pm »
Hello,
I've got a problem with executing program compiled on my Raspberry Pi. It's for communication with my 3G controlled quadcopter. I compiled it on every linux at home end it worked. Compilation on Pi succeed too, when I CMade newest source form Laurent Gomila's git. I just had to put .so files path while building. When I try to execute it, there is only en error: "Illegal instruction". It only happends on Raspberry Pi. Is there a way to fix it other than resign form using SFML?

Used commands:
g++ -c programname.cpp
g++ programname.o -o programnamebuild -L /usr/local/lib/ -lsfml-network -lsfml-system
./programnamebuild  --- And then the error occurs

Here's my code:
#include <SFML/Network.hpp>
#include <iostream>

int roll = 0;
int rcthr = 0;
int pitch = 0;
int yaw = 0;
int high = 0;

int main()
{
sf::UdpSocket listener;


sf::IpAddress nadawca;
unsigned short port = 54321;
listener.bind(port);
sf::Packet paczka;

sf::SocketSelector sel;
sel.add( listener );

while (true) {

if( sel.wait(sf::seconds(1)) ) {


        if( sel.isReady( listener ) ) {
        sf::UdpSocket client;
        //j = lista.end();
        //lista[j+1] = client;
        //std::cout<<"Klient podlaczony\n";
        sel.add( client );
        }
        if (listener.receive( paczka, nadawca, port) == sf::Socket::Done)
                {
                //std::cout<< "Blad odbierania\n";
                //}

                int id;
                paczka>>id>>roll>>pitch>>rcthr>>yaw>>high;

                std::cout<<"Od: "<<nadawca<<" (ID:"<<id<<") ->\n";
                std::cout<<roll<<", "<<pitch<<", "<<rcthr<<", "<<yaw<<", "<<high<<"\n";

                }
       
       
    }

} // end while
return 0;
}
 

Pages: [1]
anything