Okay just got TCP to work, and noticed that a binary formatter is used to make it "network friendly" i think.
Anyway, so the code is like this:
Client
Serializer.Serialize(tcpcap.GetStream(), u);
Server
byte[] u = Serializer.Deserialize<byte[]>(tt1.GetStream());
u is Not the same on both of them, i just have the same name, but u is a byte array on both parts.
And well, it doesn´t work.
It does work with:
(byte[])b.Deserialize(tt1.GetStream());
b.Serialize(tcpcap.GetStream(), u);
where b is new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
There is probably an obvious reason why it isn´t working, but i don´t really know what Serialization is, so for me, it´s not that obvious.
Solved it, or well not using protobuf, but NetSerialization, got help from the Author.
So let´s say this is answered.
Related
I have read a few older threads on this issue, and quite frankly the discussion flew over my head a bit. So I'm hoping for some help that I will hopefully be able to follow.
I am programming an STM32 with RTOS (two threads needed). It's a sensor application with some fairly intensive computation on the data gathered (hence the H7). Computation feedback is sent through CDC in the form of a char array, size 12. Nothing difficult. The computation feedback is a float. And this where I am having problems.
Prior to sending the data I need to convert the float to a char[].
my function looks like this:
void ASCII_transmitFloat(float value) {
uint8_t buffer[DEF_ASCII_TX_BUF];
snprintf((char *)buffer, sizeof(buffer), "%11.9f\n", value);
CDC_Transmit_FS(buffer, sizeof(buffer));
}
I am not getting an error, just a crash on the snprintf.
I tried sprintf with the same results
casting my float to a uint32_t and changing the arg type in my function to uint32_t, works. (I'm losing precision so this is not a solution, but tried anyway)
I have the same version of the function for integers, and these work fine as well
oh and I kinda of mickey-moused between uint8_t and char, it's probably as bad as it is ugly, but I haven't found a better way yet
anyhow thanks for any help you can provide
cheers
edit:
Editing in response to the first response.
I had the "use float with printf" option selected in the project properties (MCU settings) - see the screenshot below (not sure if this check box does the same as adding the flag manually)
I tried adding the line -u _printf_float in the linked as suggested in your link, but I have the same results. Crashes when executing the snprintf.
Here is how I fixed the problem.
The problem is known, and ST hasn't fixed the issue since it was first brought up here a year ago, see:
https://community.st.com/s/question/0D50X0000BB1eL7SQJ/bug-cubemx-freertos-projects-corrupt-memory
and here's the recommended fix:
http://www.nadler.com/embedded/newlibAndFreeRTOS.html
A bit over my head so I chose to go the route of using a lighter version of the printf function:
https://github.com/mpaland/printf
I hope it helps someone else with the issue.
Cheers
Probably because float support is not included by default using newlib.
See printf floats with newlib on STM32
This problem happened to me too. I'm not sure yours is same with mine but maybe it can help yoou. I just fixed it and the only thing i did is, i included "stdio.h". Then my warning gone.
I'm trying to use this database with react-native. First of all, i've found out that it can't retrieve plain objects - i have to retrieve all of the properties in the desired object tree recursively. And it takes about a second per object (~50 numeric props). Slow-ish!
Now, i've somehow imported ~9000 objects in it (each up to 1000 chars including titles). Looks like there is no easy ay to import it, at least it is not described in docs. Anyway, that's acceptable. But now i've found out that my database size (default.realm) is 3.49GB (!). The JSON file, which i was importing is only 6.5mb. I've opened default.realm with Realm Browser and it shows only those ~9000 objects, nothing else. Why so heavy?
Either, i don't understand something very fundamental about this database or it is complete garbage. I really hope i'm wrong. What am I doing wrong?
Please make sure you are not running in chrome debug mode. This is probably why things seem so slow. As far as the file size issue goes, it would be helpful if you posted your code to help figure out why that is happening.
I want to add an ssl support to an old chat application I wrote years ago. I did a lot of reading on OpenSSL and LibreSSL and I decided to try a new libtls API. I think developers did a really great job on this one.
I found it to be very easy to use - almost no changes to my existing code where required. But here is one thing I need to figure out now:
Back in a day, I was using select() to monitor sockets and recv() to read a data. This was easy, because both of those functions are working on file descriptors.
Now, with libtls, function tls_read() requires a tls context as a first argument. This means I need to search the list of clients to get an appropriate tls context every time I have a descriptor ready to be read. This is not that hard but maybe someone knows a better solution? I will appreciate all comments and code samples.
Unless I'm misreading the documentation, it seems to me that if you create the sockets yourself, and then use tls_connect_fds/tls_connect_socket/tls_accept_fds/tls_accept_socket afterwards, you'll have normal file handles available you can trivially use with select()/poll()/etc. You'd still need to keep around some sort of file descriptor to context mapping to actually issue the tls_read/tls_write once you were ready, but that's just your choice of linked list or hashtable, depending on what language you're using and what stdlib you have available.
I wrote a JSON encoder/decoder for Rebol 2. I'm rewriting it for Rebol 3 and would prefer to make it available in Rebol 3 as a codec:
load %data.json
save %data.json object
decode 'json to-binary {["some","json"]}
How should I go about this?
At the time of asking, documentation on this subject is scarce.
The simple answer is that you can't. As for why, there are several answers to that.
The current codec model is undocumented. Only Carl knows how to write codecs at the moment. Though someone might be able to look at the source and figure it out, noone has yet.
The current codec functions aren't really flexible enough to make what you want here. You could make a decoder, but not an encoder because encode only takes images, binaries or strings. Maybe just having a decoder is enough for you though.
Only native codecs are supported by the current model. You can't write codecs in Rebol code, and for a parser that means that you can't use parse. Do you have a native code version of your parser?
The current codec model is a placeholder for the codec model we hope to eventually have. This is why it hasn't been that well documented. We eventually hope to support incremental en/decoding, codecs that can read directly from files or other ports, and Rebol codecs. However, we haven't really decided on the final model yet, or even started the discussion of how it will be designed, beyond initial criticisms.
I wish there was a better answer to your question right now.
Codecs were imo in highly non-finished state. I proposed some kind of streamed mechanism was needed, IIRC Carl understood the need, but the solution was never imo outlined. Ditto for tasks - current "implementation" is far from what Carl envisioned for R3 tasking ...
There is a tool, read this: http://rebol2.blogspot.it/2012/12/json.html
and this:
http://www.rebol.com/article/0522.html
However json is a complex way to handle data, rebol block is perfect in my humble opinion.
I just noticed that system/catalog/codecs is removed from Rebol 3; so I suppose that the feature was removed after 31-Mar-2009.
>> ? system/catalog
SYSTEM/CATALOG is an object of value:
datatypes block! length: 56
actions block! length: 56
natives block! length: 159
errors object! [Throw Note Syntax Script Math Access Command...
reflectors block! length: 6
boot-flags block! length: 18
The project I am currently working on requires a lot of hexadecimal numbers to be entered into the code.
I once saw a pic of an old keyboard with a hexadecimal numpad (has A-F letters on it also) replacing the normal numpad. Anyone know where I can get one of these?
IPv6 Buddy -keypad should work well for hexadecimal input.
http://www.ipv6buddy.com/
If you can get your hands on one of the retired space shuttles, they have one!
I have an old Heathkit learning toy with a hex numpad because the only way to program it was to assemble code by hand (it came with a 6800 manual and some notepads) into the online monitor. This was actually fun!
Mine is missing the 'D' button however.
Great idea with the programmable keypad. I think i am going to pick up one of these: DX1 input system. Works for any reconfiguring I might want to do.
Is this the one you're talking about?
funky http://www.cpmuseum.com/Exhibits/Apple%20Lane/7603/7603-0005/images/000%20Front%20View.jpg
While this has a lot of "gee whiz" appeal, I have to say:
You have two hands. Use them. A-F are all reachable with the left hand on a standard keyboard while your right hand is on the num-pad. Instead of putting muscle-memory time into some arcane Hex-pad, you'll be learning to touch-type with your left hand, which has application outside your current project.
Better yet, come up with a smarter way of getting the hex codes into your code. Write a script that extracts them from your data-source and into your code as symbolic variables... or whatever.
EDIT
Ok, I'll give you the benefit of the doubt. Lets assume you're working on a hardware project and need to provide a specialized interface for your user. Maybe a programmable keypad would fit the bill?
Not sure of the specifics right now, but I'm pretty sure you can easily write a keyboard remapper. You could remap the QWASDF keys to ABCDEF in order to type them more quickly. That way you could use 2 hands to type. Or if you are in control of the program they are being typed into, you could just translate the keys in code on the fly. You also might want to try out the Microsoft Keyboard Layout Creator