Home
Support
¿Es Posible Escribir Directamente a un Campo de un Bit con la Función GetCtrlVal en LabWindows/CVI?
¿Es Posible Escribir Directamente a un Campo de un Bit con la Función GetCtrlVal en LabWindows/CVI?
Software Primario:
Versión de Software Primario: 8.5
Versión de Software Primario Corregido: N/A
Software Secundario: N/A
Problema: Estoy tratando de escribir directamente a un campo de un bit con la función GetCtrlVal. Obtengo un mensaje de error diciendo que el compilador de LabWindows/CVI piensa que mi campo de un bit es un LVALUE. ¿Por qué estoy recibiendo este error y cómo puedo corregirlo?
Solución: Este error ocurre porque el GetCtrlVal está esperando un apuntador a una dirección de memoria y no hay forma en C para crear un apuntador a un bit específico. La única forma de resolver esto, es crear una variable temporal para almacenar información y entonces utilizarla para escribir al campo de un bit.
Ejemplo:
typedef struct LED_Field
{
unsigned int one: 1;
unsigned int two: 1;
unsigned int three: 1;
unsigned int four: 1;
unsigned int five: 1;
unsigned int six: 1;
unsigned int seven: 1;
unsigned int eight: 1;
}LED_ARRAY;
...
static LED_ARRAY leds;
...
static void GetCurrentValues()
{
unsigned int val;
GetCtrlVal(panelHandle, PANEL_LED, &val);
leds.one = val;
}
Ligas Relacionadas: KnowledgeBase 134BPMQ0: Why Don't Bit Field Structures Pack Down into a Single Byte?
Archivos Adjuntos:
Día del Reporte: 03/28/2006
Última Actualización: 04/21/2009
Identificación del Documento: 3VRFO8K7
Other Support Options
Ask the NI Community
Collaborate with other users in our discussion forums
Request Support from an Engineer
A valid service agreement may be required, and support options vary by country.