C/C++ :: How To Write Byte In 8051 Correctly
Nov 16, 2012
i have a hex code and need to write it in 8051
if the hex code is
"11 22 33 44 55 66 77 88"
"88 77 66 55 44 33 22 11" (hexadecimal)
but the result is
11 22 33 44 55 66 77 88 FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
it is should be
11 22 33 44 55 66 77 88 88 77 66 55 44 33 22 11
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
problem is ...
it can not write second hex code
just only write first hex code
i use serial port , VB6 ,keil C
View 4 Replies
ADVERTISEMENT
Jan 22, 2015
In my application there is a structure that holds 200 parameters for 200 tests. These structure is converted to byte array . I want to write this byte array to a file in save button and when I click open button, this file must open and write these bytes to corresponding text boxes. How it possible.?
View 1 Replies
View Related
Apr 28, 2014
So I have a small program which is supposed to write and read multiple objects from a file, but for some reason it doesn't write the information when I use "fstream" to create the object from the fstream class, but it does when I use "ofstream". Also, it doesn't read the information from the file no matter if I use "fstream" or "ifstream". I watched a video where this exact code worked just fine, but it just won't work when I run it. I'm using Dev C++ 4.9.9.2, I don't know if that has anything to do with it, I also tried it with Code::Blocks, didn't work either.
Here's the code.
#include <iostream>
#include <fstream>
using namespace std;
class Person
[Code].....
View 3 Replies
View Related
Mar 30, 2013
What is the most efficient way to read a bit at a particular position in a byte?
View 13 Replies
View Related
Aug 16, 2014
Right now im creating a program that use xbox inputs and then send out keyboard functions using sendInput();
It works fine, but now im creating a system wich lets the user of the program change the settings in a textfile. Wich will then change what the controllers bindings are.
example, if settings.txt says: Y=button(0xIE)
i want the program to know that when xbox button Y is pressed, execute a sendInput function to the Key: A (0xIE).
The problem is that the virtual keycode (0xIE) i take from the settings.txt is stored as a string (lets say it is stored in string Y_event)and input.ki.wScan has to be of type BYTE. i made a function wich changes string into int. (because input.ki.wScan seems to be fine getting a int?)
int stringToInt(string insert) {
char back[20];
for(unsigned int e=0;e < insert.length();e++) {
back[e]=insert[e];
} return atoi(back);
}
but when i run the code nothing happend...
In the code i have a function wich executes the keypress: void pressbutton(int key, int time)
when i send in the converted string it doesn't work but when i send in: (0xIE) it works.
pressButton(stringToInt(Y_Event),50) // doesn't work
pressButton(0xIE,50) // works
focus on the last part that i wrote.
View 3 Replies
View Related
Mar 30, 2013
What is the most efficient way to read a bit at a particular position in a byte?
View 3 Replies
View Related
Mar 16, 2014
I'm trying to get the current time for a game and print that to the games chat window. I'm already injected into the process do I don't think I need ReadProcessMemory.
The value i'm trying to read is the game hours 1-12.
//doesn't work
byte time_hour_get ( void )
{
return *( byte *)0x00B70153; //the address to the memory containing the
}
addMessageToChatWindow((char*)time_hour_get); -> when I call this function it looks like s , . I want it to return the integer value like cheat engine. I used byte when scanning for this address
View 1 Replies
View Related
Feb 17, 2015
so i have this problem with my code ( not running)i want to read ( 2 double numbers x,y) and ( one integer z) then calculate reminder of x and y ( after they both converted to integer) and the formula : x^2 + y^2 + z^2and : x^z + y^z
here is what i came up with :
Code:
// compute.c
#include<stdio.h>
#include<math.h>
int main(void)
{
[Code]....
it also says in q : be sure to test the user input to make sure x,y,z are positive . any negative or zero should not be accepted and must print error msg ==> do i have to have an if statement here ? or the while loop is enough ?
View 9 Replies
View Related
Jan 23, 2015
I'm working on a school assignment that asks us to make code calculating the quadratic formula.
Code:
#include <stdio.h>
#include <math.h>
int main(void) {
double a = 0;
double b = 0;
double c = 0;
double discriminant = 0;
double solution = 0;
double solution2= 0;
}
[code]....
View 4 Replies
View Related
Apr 13, 2014
Basically it has to do with the byte ordering in a binary buffer vs the typing of a variable used to hold it.
To give you an example, if I have a buffer (say of indefinite length), and a ptr "ptr" pointing to a byte in the buffer (say, C0), such that if I open the buffer in a binary viewer it reads like this: Code: C0 DD FE 1F Such that this is true:
Code:
/*ptr is uint8_t*/
*ptr == 0xC0
Then I do this:
Code:
uint16_t var;
var = *(ptr+1);
I would expect the result to be:
Code: DD FE /*56830*/
Though if I print that out with:
Code:
printf("%u
", var);
It'll print:
Code: 65245 /*(FE DD)*/
Now obviously it's byte swapped, but what is causing that? I'm assuming if I just stream that out to a file byte by byte it'll be fine, so it's something with the 16 bit data type (also have seen this issue with a 32 bit data type, where all 4 are in reverse order). Is there any way to 'fix' it except bit shifts & masks?
View 14 Replies
View Related
Sep 20, 2014
Are locations in the RAM addressed per word or per byte? I am using a 32 bit machine, so I think that it means that on my PC a word would be 4 bytes.
View 11 Replies
View Related
Jun 25, 2014
I basically want to create a save editor application that will enable people to alter various values in the save by clicking on releveant buttons and then also for the editor to auto update the checksum when changes are done.
The save file is in hex so from what I can gather I would need to create a button to open the file using 'open file dialogue' and then read the file into a byte array so that the values can be called at any time when a particular butto is pressed and the application will then seek to the point in the file to make the required changes.
View 3 Replies
View Related
Oct 7, 2014
I have an application that has its own embedded web server. I am trying to add jQuery/Ajax file upload capabilities to the application however, I am running into issues getting the posted file. The jQuery/Ajax portion is similar to this method here. Due to the way the webserver was written (its in a dll and I do not have access to the source), the posted file comes in as a byte[]. If I try to save the byte array directly to file using:
File.WriteAllBytes("path", ByteArray)
I end up with a corrupt file that I cannot open. I believe this is because the byte array also contains the posted file header info (Content-Disposition, name, filename, etc.). If I view the contents of the byte array using:
System.Text.Encoding.Default.GetString(ByteArray)
the header info can be viewed as:
------WebKitFormBoundaryQfPjgEVpjoWgA5JL
Content-Disposition: form-data; name="0"; filename="someimage.png"
Content-Type: image/png
‰PNG
Based on the selected file size and the size of the byte array, the entire file is in the byte array. How can I go about extracting and saving the posted file from the byte array?
View 2 Replies
View Related
Jun 8, 2014
how to use this function:
ftStatus = myFtdiDevice.Read(readData, numBytesAvailable,ref numBytesRead);
to read byte from the serial port.This function is part of the DLL that came with the chip(FT2232D) I am using on my board.I want to use the function to read a byte from the serial port and then send the value to the Graphic user interface.Unfortunately I was unable to get the expected value on my GUI.If I send for instance 40,what I get on the GUI are letters instead of the number 40 or at times the GUI will not even respond.Below are my lines of code I used to read the byte from the serial port:
The following instructions are executed whenever the CHECKBOX is checked
private
void checkBox1_CheckedChanged(object sender, EventArgs e)
{
UInt32 numBytesRead = 0;
[Code].....
View 3 Replies
View Related
Feb 26, 2012
Trying to write very simple code to read a 4 byte int from a file.
code:
int tester;
FILE *fp;
fp=fopen("/home/bdluser/skeleton.blx","rb");
fread(&tester,sizeof(int),1,fp);
printf("tested 1 byte read should be 1: %i",tester);
I have tried editing the binary file....it outputs similar large numbers
00000000000000000000000000000001 outputs 808464432
0x00000001 outputs 808482864
0x10000000 outputs 808548400
10000000000000000000000000000000 outputs 808464433