floats do not have to be alligned.

main
Steffen Pohle 4 weeks ago
parent 8b1c30475c
commit 8844317ba0

@ -1,5 +1,5 @@
.SILENT: help .SILENT: help
VERSION = 0.1.9 VERSION = 0.1.10
-include Makefile.rules -include Makefile.rules
@ -90,7 +90,7 @@ buildwindows: clean
./copydlls.sh ./copydlls.sh
./copydlls.sh ./copydlls.sh
./copyshare.sh ./copyshare.sh
cp /usr/lib/gcc/x86_64-w64-mingw32/13-win32/*.dll TestModbus-Client-$(VERSION)/ cp /usr/lib/gcc/x86_64-w64-mingw32/14-win32/*.dll TestModbus-Client-$(VERSION)/
for i in `ldd TestModbus-Client.exe |grep -vi "/c/windows" | cut -d" " -f3`; do cp $$i TestModbus-Client-$(VERSION)/; done for i in `ldd TestModbus-Client.exe |grep -vi "/c/windows" | cut -d" " -f3`; do cp $$i TestModbus-Client-$(VERSION)/; done
mv *.dll TestModbus-Client-$(VERSION)/ mv *.dll TestModbus-Client-$(VERSION)/
mv share TestModbus-Client-$(VERSION)/ mv share TestModbus-Client-$(VERSION)/

@ -189,7 +189,7 @@ gboolean mbcli_thread_cb_modbusdata(gpointer data) {
// integer values (16bit words) // integer values (16bit words)
// //
gtk_text_buffer_get_end_iter(textbuffer, &end); gtk_text_buffer_get_end_iter(textbuffer, &end);
gtk_text_buffer_insert_with_tags_by_name(textbuffer, &end, " Addr RawData Integer Float Float(SW)\n", -1, "Head", NULL); gtk_text_buffer_insert_with_tags_by_name(textbuffer, &end, " Addr RawData UInt16 SInt16 Float Float(SW)\n", -1, "Head", NULL);
for (int i = 0; i < res->cnt; i++) { for (int i = 0; i < res->cnt; i++) {
// add addr to textbuffer // add addr to textbuffer
@ -199,18 +199,18 @@ gboolean mbcli_thread_cb_modbusdata(gpointer data) {
// add data to textbuffer // add data to textbuffer
text = to_hex16((int) res->data[i]); text = to_hex16((int) res->data[i]);
if ((res->reg + i)%2 == 0 && i < res->cnt-1) { if (i < res->cnt-1) {
memcpy (((char*)&f1) + 0, &res->data[i], 2); memcpy (((char*)&f1) + 0, &res->data[i], 2);
memcpy (((char*)&f1) + 2, &res->data[i+1], 2); memcpy (((char*)&f1) + 2, &res->data[i+1], 2);
memcpy (((char*)&f2) + 2, &res->data[i], 2); memcpy (((char*)&f2) + 2, &res->data[i], 2);
memcpy (((char*)&f2) + 0, &res->data[i+1], 2); memcpy (((char*)&f2) + 0, &res->data[i+1], 2);
snprintf (tmp, 255, " | %6d | %9.3g | %9.3g", res->data[i], f1, f2); snprintf (tmp, 255, " | %6d | %6d | %11.5g | %11.5g", res->data[i], (int16_t) res->data[i], f1, f2);
text = text + tmp; text = text + tmp;
} }
else { else {
snprintf (tmp, 255, " | %6d | | ", res->data[i]); snprintf (tmp, 255, " | %6d | %6d | | ", res->data[i]);
text = text + tmp; text = text + tmp;
} }

Loading…
Cancel
Save