Click here to Skip to main content
15,884,066 members
Home / Discussions / C#
   

C#

 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox6-Jul-20 7:27
professionalpkfox6-Jul-20 7:27 
GeneralRe: Strange characters in JSON RPC server response Pin
Luc Pattyn6-Jul-20 7:43
sitebuilderLuc Pattyn6-Jul-20 7:43 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox6-Jul-20 8:05
professionalpkfox6-Jul-20 8:05 
QuestionIntegers to Float IEEE 754 Pin
Member 1487212830-Jun-20 16:39
Member 1487212830-Jun-20 16:39 
AnswerRe: Integers to Float IEEE 754 Pin
Luc Pattyn30-Jun-20 17:29
sitebuilderLuc Pattyn30-Jun-20 17:29 
GeneralRe: Integers to Float IEEE 754 Pin
Member 148721281-Jul-20 5:44
Member 148721281-Jul-20 5:44 
GeneralRe: Integers to Float IEEE 754 Pin
Luc Pattyn1-Jul-20 5:50
sitebuilderLuc Pattyn1-Jul-20 5:50 
GeneralRe: Integers to Float IEEE 754 Pin
Member 148721281-Jul-20 6:08
Member 148721281-Jul-20 6:08 
Trying to work through this, I have attempted the following, but get a compile error.

int val1 = 17352;
            int val2 = 9147;
                     

            byte[] buffer = { (byte)val1, (byte)val2 };
            for (int n = 0; n < buffer.Length; n += 2)
            {
                short sample = (short)BitConverter.ToSingle(buffer, n);
                MessageBox.Show(sample.ToString());
            }


The exception that I currently get is: Could you help a bit more? I was able to fix the title......
Quote:
System.ArgumentException
HResult=0x80070057
Message=Destination array is not long enough to copy all the items in the collection. Check array index and length.
Source=mscorlib
StackTrace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.BitConverter.ToSingle(Byte[] value, Int32 startIndex)
at WindowsFormsApp2.Form1.tmr_Modbus_Conn_Tick(Object sender, EventArgs e) in C:\Users\Justin Fehl\Documents\Visual Studio 2019\Projects\ModBus Development\ModbusTest2.cs:line 94
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApp2.Program.Main() in C:\Users\Justin Fehl\Documents\Visual Studio 2019\Projects\ModBus Development\Modbus Development 6-26-2020\WindowsFormsApp2\Program.cs:line 19

GeneralRe: Integers to Float IEEE 754 Pin
Luc Pattyn1-Jul-20 6:12
sitebuilderLuc Pattyn1-Jul-20 6:12 
GeneralRe: Integers to Float IEEE 754 Pin
Member 148721281-Jul-20 6:18
Member 148721281-Jul-20 6:18 
GeneralRe: Integers to Float IEEE 754 Pin
Member 148721281-Jul-20 8:09
Member 148721281-Jul-20 8:09 
GeneralRe: Integers to Float IEEE 754 Pin
Luc Pattyn1-Jul-20 9:29
sitebuilderLuc Pattyn1-Jul-20 9:29 
QuestionHow can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w30-Jun-20 11:14
arnold_w30-Jun-20 11:14 
AnswerRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Dave Kreskowiak30-Jun-20 11:18
mveDave Kreskowiak30-Jun-20 11:18 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w30-Jun-20 11:36
arnold_w30-Jun-20 11:36 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Dave Kreskowiak30-Jun-20 11:59
mveDave Kreskowiak30-Jun-20 11:59 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Luc Pattyn30-Jun-20 11:48
sitebuilderLuc Pattyn30-Jun-20 11:48 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Dave Kreskowiak30-Jun-20 11:59
mveDave Kreskowiak30-Jun-20 11:59 
AnswerRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Luc Pattyn30-Jun-20 12:35
sitebuilderLuc Pattyn30-Jun-20 12:35 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w30-Jun-20 19:52
arnold_w30-Jun-20 19:52 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
kalberts1-Jul-20 0:09
kalberts1-Jul-20 0:09 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w1-Jul-20 0:15
arnold_w1-Jul-20 0:15 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Luc Pattyn1-Jul-20 1:08
sitebuilderLuc Pattyn1-Jul-20 1:08 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
arnold_w1-Jul-20 1:58
arnold_w1-Jul-20 1:58 
GeneralRe: How can I find out what "USB Serial Device" is called in all other languages? Pin
Luc Pattyn1-Jul-20 2:08
sitebuilderLuc Pattyn1-Jul-20 2:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.