Comments (3)
You need a sufficiently big enough buffer. Depends on what you want to write.
If you also have a vnsprintf implementation, you can use the trick mentioned in the sprintf man page
under the section EXAMPLE:
// To allocate a sufficiently large string and print into it (code correct for both glibc 2.0
// and glibc 2.1):
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
char *
make_message(const char *fmt, ...)
{
int size = 0;
char *p = NULL;
va_list ap;
/* Determine required size */
va_start(ap, fmt);
size = vsnprintf(p, size, fmt, ap);
va_end(ap);
if (size < 0)
return NULL;
size++; /* For '\0' */
p = malloc(size);
if (p == NULL)
return NULL;
va_start(ap, fmt);
size = vsnprintf(p, size, fmt, ap);
va_end(ap);
if (size < 0) {
free(p);
return NULL;
}
return p;
}
Another possibility to implement printf in a way to output each and every character right on the spot, therefore no memory allocation needed at all. I've used sprintf to show you how it's done, and it was obvious to reuse that code for printf. But that's not the only way.
from raspi3-tutorial.
Just as a side note would you mind having a look at my post on the pi forums about audio please?
from raspi3-tutorial.
I finished a way to malloc memory for printf it is in my github repo if you wanted to look at it. I was unable to find how circle does audio so would you please check out this post: https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=212930&sid=aeafdbf5f08d4d0563e61392c6cac157
from raspi3-tutorial.
Related Issues (20)
- Reference document to understand code and commands in 0B_readsector HOT 1
- 0x1C2 no longer has 0xE or 0xC partition type HOT 2
- 0B ReadSector - Stable clock troubleshooting HOT 8
- Typos - bareminimum readme HOT 3
- Using sd_readblock() for reading directories HOT 9
- 0A PCScreenFont only works in QEMU HOT 7
- 0B_readsector stuck after EMMC: Sending command 33220010 arg 00000000 HOT 1
- Segmentation fault on execution of 09_framebuffer and 0A_pcscreenfont HOT 6
- Using U-boot to boot kernel8.img HOT 2
- about the uart HOT 4
- Emulating the raspi 3 on jetson nano failed with a black screen. HOT 1
- Explanation for mailboxes HOT 4
- How to tune the booting parameters of Lineage 16 for Raspi 3 to boot it with qemu / kvm on the Jetson nano... HOT 1
- 14_raspbooin64 HOT 5
- Please help to understand the load address 0x800000 in the linker file HOT 2
- uart0 tutorial issue HOT 1
- Why *EMMC_INTERRUPT=*EMMC_INTERRUPT; in sd.c? HOT 1
- How do you debugger with gdb-multiarch? HOT 6
- Why ptr+=4 or ptr+=3? HOT 7
- qemu emulation not working HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raspi3-tutorial.