Questions tagged [uint16]

127 questions
1
vote
1 answer

Python: convert array of uint16_t to string (from Arduino over RS-485)

I'm trying to send json over modbus rtu (I know, it is very bad use of modbus.) My schema is similar to: I have connected Arduino USB to PC as COM5 and RS485 converter connected to USB-RS485 to PC as COM4. If I read data from Arduino using QModBus…
martin
  • 1,707
  • 6
  • 34
  • 62
1
vote
1 answer

Convert float values to uint8 array in javascript

I have a Float32Array with values from an audio file.I want to save it as a .wav file so I need to convert that values to a Uint8array. To convert from uint8 to float I convert first to an int16 array and then to a Float32Array (Convert int16 array…
user7597554
  • 95
  • 4
  • 11
1
vote
2 answers

Convert int16 array to float

I have an array of bytes from an audio file and I want to convert it into data that I can process to filter the audio signal. I have an array like this: [239,246,96,247.....]; Each element is a uint8 byte Each 2 bytes(16 bits) represent a sample,so…
user7597554
  • 95
  • 4
  • 11
1
vote
2 answers

Combining 2 uint16_t into into 1 uint32_t

I have 2 uint16_t's that i want to combine into 1 32 bit number: uint16_t var1 = 255; // 0000 0000 1111 1111 uint16_t var2 = 255; // 0000 0000 1111 1111 uint32_t var3 = (var1 << 16) + var2; I expect var3 to be 0000 0000 1111 1111 0000 0000 1111…
user4292309
1
vote
1 answer

Value of uint8_t after being converted from uint_16t

I have to do a small assignment for school. I am writing this in C. The question is: Given uint16_t A[] = { 0xabce, 0x43fe, 0xcf54, 0xffff }; uint8_t *p = (uint8_t *)&A[0]; What is the value of p[3]? I did some research and found that the numbers…
LvanRooij
  • 86
  • 7
1
vote
2 answers

How to create 3D array of optionals w/ set size

How would I go about creating a 3-dimensional array of UInt16? with a set size where each element is by default set to nil? My attempt was var courseInfo = UInt16?(count:10, repeatedValue: UInt16?(count:10, repeatedValue: UInt16?(count:10,…
Lahav
  • 781
  • 10
  • 22
1
vote
2 answers

uint16_t subtraction GCC compilation error

I have the following program #include #include #include int main(void) { uint16_t o = 100; uint32_t i1 = 30; uint32_t i2 = 20; o = (uint16_t) (o - (i1 - i2)); /*Case A*/ o -= (uint16_t) (i1 -…
Mohamed
  • 265
  • 3
  • 6
1
vote
1 answer

How to bit-shift and concatenate to get correct result?

I'm currently struggling with modbus tcp and ran into a problem with interpreting the response of a module. The response contains two values that are encoded in the bits of an array of three UInt16 values, where the first 8 bits of r[0] have to be…
Rob
  • 11,492
  • 14
  • 59
  • 94
1
vote
1 answer

C: fread does not read the full block

Here's my code so far: #include #include #define N_DET 432 #define N_PROJ 500 int readSinogram(uint16_t mess[],char filename[], int sample){ //init FILE *fp; int i; //open file fp=fopen(filename,"r"); …
Dominic
  • 452
  • 4
  • 20
1
vote
1 answer

a gettime() function that returns a uint16_t value in C

Hi I'm trying to do a getTime() function that returns uint16_t in C. I do can successfully get an array of chars now Here's my code for a output of array of chars. Say today is Dec 9 2014 the output will be 091214 So how can i make the output a…
Shanji
  • 15
  • 4
1
vote
1 answer

Convert string with space separators to uint16

Hi I need help to convert a string to array of uint16 my string look like: Dim test as String = "4 7 9 10 11 12 14 15 16 17 19 23 24 25 26 27 28 29 30 32 33 37 40 42 48 58 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79" And I need to convert that…
1
vote
1 answer

Convert String to UInt16 Objective-C

I am facing the problem, that I can't convert an string or an int to an UInt16. This is my current code: (UInt16)[[defaults stringForKey:@"port"] intValue] [[defaults stringForKey:@"port"] intValue] is 8080 and (UInt16)[[defaults…
David Gölzhäuser
  • 3,525
  • 8
  • 50
  • 98
1
vote
1 answer

Converting uint16 from ADC flips negative

What I want to do: Turn the resulting 16bit number (after combining the two 8bit #s) into a string to use with my serial send function The problem: When using itoa, the result becomes negative once it passes the half way point (passing from the 15th…
Nick Yang
  • 13
  • 2
1
vote
1 answer

How can I pass in a pointer to a pointer of a UInt16 array to a Marshalled function?

I'm attempting to send a pointer to a pointer of a UInt16 array to a marshalled function like so in C#: C++: int foo(Unsigned_16_Type** Buffer_Pointer); C#: [DllImport("example.dll")] public static extern int foo(IntPtr Buffer_Pointer); UInt16[]…
user2134127
  • 135
  • 1
  • 2
  • 9
1
vote
1 answer

Converting 16-bit integer to 8-bit integer?

I'm implementing C code to copy a 16-bit sign and magnitude integer to an 8-bit sign and magnitude integer. Is that even possible? Could someone please explain how to do this? code snippet: int16_t a = 0x1234; int8_t b, c; How to copy first two…
Rohith Gowda
  • 137
  • 2
  • 2
  • 12
1 2 3
8 9