minor changes

master
Bartosz Kostrzewa 2010-11-12 16:43:27 +01:00
parent 6679ce8e61
commit e1b1e41e00
6 changed files with 24 additions and 13 deletions

View File

@ -3,13 +3,10 @@
Buffer::Buffer( int _id )
{
id = _id;
// allocate memory
}
Buffer::~Buffer()
{
// deallocate memory
}
void Buffer::set(frame_t data)

View File

@ -22,6 +22,16 @@ void Server::launch_threads()
threads.push_back( Glib::Thread::create( sigc::mem_fun(this, &Server::mix), false ) );
}
/* this listens for UDP connections on a port and waits until there is data,
processes it and repeats */
/* TODO
error and format checking
clean exit conditions
ability for one client to take over the display
*/
void Server::listen()
{
int packetcounter = 0;
@ -30,13 +40,15 @@ void Server::listen()
boost::asio::io_service io_service;
// next line is NOT thread-safe because we're accessing "port" without lock
// however, it is done only once before any other threads are started and
// should be safe
udp::socket socket(io_service, udp::endpoint(udp::v4(), port));
cout << "listening" << endl;
for (;;)
while (1)
{
frame_t frame;
boost::array<char, 200> recv_buf;
boost::array<char, BUFLEN> recv_buf;
udp::endpoint remote_endpoint;
boost::system::error_code error;
@ -80,6 +92,7 @@ void Server::listen()
std::string message = "received";
boost::system::error_code ignored_error;
// we can provide feedback to clients
//socket.send_to(boost::asio::buffer(message),
// remote_endpoint, 0, ignored_error);
}
@ -90,6 +103,11 @@ void Server::listen()
}
}
/* the framemixer, this periodically (40 times a second) reads all input
buffers and then produces output, ready to be displayed.
In the final version, this is where interesting things will happen.
*/
void Server::mix()
{
int size = 0;

View File

@ -1,6 +1,7 @@
#ifndef __DEFINES_H_
#define __DEFINES_H_
#define BUFLEN 1024
#define NUMBUFS 100
#define WIDTH 12
#define HEIGHT 7
#define SEGWIDTH 12
@ -18,4 +19,4 @@ struct frame_t
segment_t segments[SEGWIDTH];
};
#endif
#endif

View File

@ -1,8 +1,6 @@
#!/bin/bash
i="0"
while [ 1 ]
do
echo "$1" | cat - display | netcat -q 0.1 -u 127.0.0.1 4321
done
done

Binary file not shown.

View File

@ -12,10 +12,7 @@
#include "Buffer.h"
#include "Buffers.h"
#define NUMBUFS 10
using namespace std;
Buffers* buffers;
int main(void)
{
@ -25,7 +22,7 @@ int main(void)
// our main loop with support for signals and all that jazz
Glib::RefPtr<Glib::MainLoop> Main = Glib::MainLoop::create();
Server server(10,4321);
Server server(NUMBUFS,4321);
server.launch_threads();
Main->run();