x65 patching technical discussion Ok, I do the beginning. Please Post only technical articles here. @Mod please make this sticky File Handling fopen Code: typedef int (*g_fopen)(const char * cFileName, unsigned int iFileFlags, unsigned int iFileMode, unsigned int *ErrorNumber); Code: typedef void (*g_fclose)(int FileHandler, unsigned int *ErrorNumber); Code: typedef void (*g_fflush)(int FileHandler, unsigned int *ErrorNumber); Code: typedef unsigned int (*g_lseek)(int FileHandler, unsigned int offset, unsigned int origin, unsigned int *ErrorNumber); Code: typedef void (*g_fread)(int FileHandler, char *cBuffer, int iByteCount, unsigned int *ErrorNumber); Code: typedef void (*g_fwrite)(int FileHandler, const char * cBuffer, int iByteCount, unsigned int *ErrorNumber); Code: typedef void (*g_SetFileSize)(int FileHandler, unsigned int iNewFileSize, unsigned int *ErrorNumber); Seek Code: #define S_SET 0 Code: #define P_WRITE 0x100 Code: #define A_ReadOnly 0 Code: int iFileHandler Code: int iFileHandler |
i also collected some functiones in my databse here: http://d23.2chaos.de/index.php?page=...&lang=en&mid=2 i added acid's functions. they are so cool, thx acid |
@acid: i want to read a unicode text file. to make sure it is only loaded to ram once i want to check the first 2 bytes of the file (if it is unicode: first word in file is 0xFFFE). i did it like this: ... if (iFileHandler != -1 && cFileOutput[0] != 0xFE && cFileOutput[1] != 0xFF) { // get the file size: ... compiles with no problems, but when i test it on the phone it crashes. if i remove "&& cFileOutput[1] != 0xFF" it works. it doesn't seem to like "cFileOutput[1]". i also can't declare another pointer to ram in the function, even if i don't use the pointer the phone crashes. what did i do wrong? sexit code says Data_Abort! at address 0xA128D51C... thx in advance |
Test it as follows: .... if (iFileHandler != -1 && *(unsigned short*)cFileOutput != 0xFFFE) { .... if memory need bound allign to WORD, it possibly crashes! |
Quote:
(*(unsigned long*)cFileOutput >> 16) != 0xFFFE |
Quote:
(*(unsigned long*)cFileOutput & 0xFFFF) != 0xFFFE |
thanks guys! "&& *(unsigned short*)cFileOutput != 0xFFFE" works, but i can't increment the cFileOutput pointer, f.ex. "cFileOutput += 2;" or "cFileOutput[2]". should i use a const char* instead? i need to access the data that are copied to ram. compiles correctly, but phone crashes with Data_abort. maybe the compiler messes something up... another way: does any of these functions return a pointer to the beginning of the file in FFS? single said it won't be fragmented for small files. then i won't have to copy it into ram... |
Quote:
|
Quote:
e.x Code: ..... Quote:
|
yes, it's possible to access the files directly from file system, but it's no good idea to do this. Because you can't write this file without implement an flasher. And you don't know if the file is already opened. Better use only 4 Bytes aligned Access if you want to be shure. Or even better, do some tests what addesses can be accesses in what way. |
i didn't succed in reading files correctly, but i made an addition to at+cgsn: Code: void Binary(const char* str) { |
I think it's hard to make the phone not freezing. Because you would have to write an routine running in background and calling itself by an timer for example, if routine is finished don't setup the timer at it's end. The big problem: You want to do this in an AT Command. I don't know what the phone will do if we just call SendATAnswerStr() while other AT Actions already finished. Can we call this from any routine? Or do we need some Init? Maybe use an AT Progress? (Sending some dots) Do anyone know how to access the Display? EDIT: @arsh0r do we really need this: iFileSize = lseek(iFileHandler, 0, S_END, &iError); in every loop? I think the file pointer is increasing with the write routine. Maybe this will make it little faster. And the other thing: Why do you search the end of the file? It would be better to search the start. - create file if it don't exists - open - search start - LOOP WRITE because you are appending the data to an file if it already exists so we don't have an exact memory map, because we don't know the old file size. |
dump ram to binary file 1 Attachment(s) it works, at+cgsn:bA8000000 dumps 1 MB of RAM to binary file in less than 10secs. does anyone know how to write files to mmc, it'll be slower, but we can dump full 8MB ram to file on mmc? because my FFS is mostly occupied *g*. but sadly SendATAnswerStr, can't send anything during this operation (output is 0A...) @acid: you're right lseeking everytime is nonsense |
@arsh0r try to send status with this routine: SendCommChar Code: typedef void (*g_SendCommChar)(unsigned char cChar); |
SendCommString Code: typedef void (*g_SendCommString)(unsigned char *cString); |
All times are GMT +1. The time now is 18:02. |
vBulletin Optimisation provided by
vB Optimise (Pro) -
vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
- GSM Hosting Ltd. - 1999-2023 -