|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#1
|
||||
|
||||
|
The DevServer TCP-based data server
I have been working on a project to make communications between multiple devices on the field quite simplistic. I present to you, the DevServer. It is an HTTP (TCP) based server, where the Java or C++ API can send and retrieve values, and at the same time, have them available on other devices on the network.
Features: Mostly STL C++, some DLib, with most headers commented out. Amazing web interface, which is clean, fast and works well AJAX for most web loading! The web pages are loaded into RAM on runtime, so the load times are quite minimal C++, Java, and possibly JavaScript(browser) APIs will be released soon Most of you will be wondering, what is this, and why I made this. This is a server, in which you can store and access data through. It supports multiple clients at the same time, so it can be used for passing data between a coprocessor and the cRIO. This nifty server comes bundled with a powerful web interface which has documentation, a way to send values, and a way to monitor all the values in real time. Based off vanilla JavaScript, the web interface requires no client setup. However, it is designed for webkit, so it may not display properly in FireFox and IE. The code is available on GitHub, [HERE] If you want to automatically download and install the server in Debian/GNU Linux, I have written an installer, and a simple one-line command to install: Run this command: PHP Code:
The red boxes on the side are debug and control boxes. The X button shuts down the server. The R button is meant to reload all the dependencies, but is currently broken! The shut down button is disabled by default, however, because when I set up my demo, people were shutting down the server. To re-enable it, enter dserv/src and comment out "#define DISABLE_REMOTE_SHUTDOWN". You can change the port number and a number of different settings from this file too. However, make sure to recompile! Recompiling: Directory(dserv/src) PHP Code:
WINDOWS USERS: I will be providing a Visual Studio 2012 Express solution soon. While this will probably be tomorrow, it will be solely based off the number of changes I will need to make to the code to make it compile, and how much time I have on hand!Suggestions are welcome. I want this to be amazing! Last edited by yash101 : 03-09-2014 at 01:20. |
|
#2
|
||||
|
||||
|
Re: The DevServer TCP-based data server
What kind of advantages does this feature over networktables?
|
|
#3
|
||||
|
||||
|
Re: The DevServer TCP-based data server
I will be creating an easy-to-use C++ and Java API, as well as a browser JavaScript API. This means that you will be able to use my server for most platforms with ease!
Also, I am making the debugging and testing interface with quality in mind! |
|
#4
|
||||
|
||||
|
Re: The DevServer TCP-based data server
You could program other data types that a network table does not have.
|
|
#5
|
||||
|
||||
|
Re: The DevServer TCP-based data server
Quote:
The main problem about NetworkTables is compatibility. I have not found a straightforward way to communicate between the robot and embedded Linux. This is a great hassle because I want to perform the expensive calculations, etc. on a coprocessor running Linux. Also, this program is built for a different reason. Firstly, I am not done with this project. I will be adding a load of features. My next plan is a way to push update notifications to the web interface so I can let y'all know when an update is available. Until then, this thread is probably the best place too look. This program is designed for hacking. Send whatever Strings you want (Just make sure they are URLEncoded for max-support!). Make you programs use variables from this system. Want to change something on the fly? Just open the web interface and use the Inject tab to do the work! Note that the program you want to load these values will need to pull from the server to get the new values! A single configuration file for all!!!: I will be adding a configuration utility, so you can actually use a centralized config file and send the values to the other robots. Web-based joysticks! Well, I am getting a bit farther than I know! Once I have the JavaScript knowledge required, I want to work on a web-based AJAX Joystick(s)! And more... I like suggestions, and if I catch my eye on one, I may actually implement it! That said, please leave me suggestions when you want! Hacking continued... Remember that this is FIRST, so it is GP to make my source code available to the general public. Make any mods you want, and have fun making things an breaking things. Just, don't use it for commercial purposes ![]() |
|
#6
|
||||
|
||||
|
Re: The DevServer TCP-based data server
Have you had issues with the existing Java, C++, and Python libraries for Network Tables? You can include the source for any of these when building a Linux executable/script, they are not dependent on platform.
|
|
#7
|
||||
|
||||
|
Re: The DevServer TCP-based data server
Sorry for highjacking the thread, but do you know where I may download the Network Tables library for C++? I've only found the Python library by Dustin and the JAR file included in the SunSpotFRC SDK files.
|
|
#8
|
||||
|
||||
|
Re: The DevServer TCP-based data server
Quote:
Quote:
|
|
#9
|
||||
|
||||
|
Re: The DevServer TCP-based data server
Quote:
Also, the main benefit to this system is the web-based interface! I today finished my Visual Studio Project, so now you should be able to get the code running in Windows in no time! Follow this link to get to the solution. |
|
#10
|
||||
|
||||
|
Re: The DevServer TCP-based data server
Quote:
|
|
#11
|
||||
|
||||
|
Re: The DevServer TCP-based data server
Just use the safely stored backup copy your team made on kickoff day as part of the inventory process.
|
|
#12
|
||||
|
||||
|
Re: The DevServer TCP-based data server
One possible issue I see is that you never seem to lock data during reads/writes. If you're managing (potentially) high-volume accesses of data, asynchronous reads and writes of un-locked data could lead to race conditions and/or data corruption. I haven't closely inspected your code, but it appears you are using threading for save_file_fs_async(). Consider the case where that data is being read during an asynchronous save. Implementing even a simple lock system would prevent undesired behavior.
Unrelated: some commenting of your code would go a long way. In its current state, your code makes it difficult to quickly understand what is going on. Consider commenting a description of what each function does and what its parameters are. Good work so far! |
|
#13
|
||||
|
||||
|
Re: The DevServer TCP-based data server
Quote:
![]() |
|
#14
|
||||
|
||||
|
Re: The DevServer TCP-based data server
Quote:
It is not that RAMCache (the function that you pointed out). I actually only do filesystem reads on server launch. there are no writes, whatsoever. I am running this server on my Raspberry Pi (and the latency is actually quite low). Whenever I use ab and send 1024 requests to the server with a concurrency of 32 or higher, I have a random chance of experiencing a segmentation fault. I am really confused about this, however. I use an automatic mutex to ensure my mutex is unlocked when it goes out of scope. However, I still continue to get these faults and since I am multithreading, they are nearly impossible to track. The entire server is multithreaded. Every request == one new thread on the system. Those threads only last a couple of miliseconds, however. The server gives around 15ms responses on average running on a Raspberry Pi! I have a feeling that my Mutexes are not locking properly. All this magic happens in server.hpp, where there is a web server class with one function! Could you please take a look at what could be going wrong. Not that I am thinking about it, I actually have a slight feeling that when I bombard the pi with requests, those threads are spawned at nearly the same time, so there are multiple threads locking the data! However, there's another thing that concerns me: It crashes when Google Chrome sends it's idle requests to the server. Every one second, I send a heartbeat request. I also start running my table monitor. After a while (not always a while, sometimes a minute or two), the server gives me a segfault or something nastier. NOTE: I just did a test where I put the server under extreme load (256 request concurrency). Every once in a while, the server showed garbled text, meaning that the mutexes aren't properly working. Could you please take a look at my Mutex implementation? GitHub Address: Here Also, about commenting: I am quite wierd about commenting, myself . Sometimes, I use too many comments. Sometimes, I barely use any at all!I'm considering an upcoming server rewrite. It's funny how the server took me an hour or two to make, while the interface took like a week. i'll be keeping the web interface the same! This might allow me to completely figure out all these problems I will just use C++11/14 because it will offer many performance improvements and built in threading/mutex mechanics! The HashMap will offer a better performance than std::map! My goal is to have this fully built in Posix STL C++! pthread will be one of the only notable exception. Does anyone know how to fix the problem in my screenshot? It is really confusing me. I don't really use pointers much of anywhere. It can be DLib, but everything was working fine not too long ago. Last edited by yash101 : 17-09-2014 at 01:21. |
|
#15
|
||||
|
||||
|
Re: The DevServer TCP-based data server
I was doing some small performance tests using localhost. This test was conducted entirely on a RasPi in Turbo mode, with one UART terminal and 2 SSH terminals. I had a 95% of the responses completing in 6ms or less!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|