1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Pictbridge Application */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_pictbridge.h"
#include "ux_device_class_pima.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_pictbridge_dpsclient_object_data_get PORTABLE C */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function returns the data of the object. */
/* */
/* INPUT */
/* */
/* pima Pima instance associated */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* */
/* CALLED BY */
/* */
/* user application */
/* */
/**************************************************************************/
UINT _ux_pictbridge_dpsclient_object_data_get(UX_SLAVE_CLASS_PIMA *pima, ULONG object_handle, UCHAR *object_buffer, ULONG object_offset,
ULONG object_length_requested, ULONG *object_actual_length)
{
UX_PICTBRIDGE *pictbridge;
UX_SLAVE_CLASS_PIMA_OBJECT *object_info;
UCHAR *pima_object_buffer;
ULONG actual_length;
UINT status;
/* Get the pointer to the Pictbridge instance. */
pictbridge = (UX_PICTBRIDGE *)pima -> ux_device_class_pima_application;
/* Check the object handle. If this is handle 1 or 2 , we need to return the XML script object.
If the handle is not 1 or 2, this is a JPEG picture or other object to be printed. */
if ((object_handle == UX_PICTBRIDGE_OBJECT_HANDLE_HOST_RESPONSE) || (object_handle == UX_PICTBRIDGE_OBJECT_HANDLE_CLIENT_REQUEST))
{
/* Check what XML object is requested. It is either a request script or a response. */
if (object_handle == UX_PICTBRIDGE_OBJECT_HANDLE_HOST_RESPONSE)
object_info = (UX_SLAVE_CLASS_PIMA_OBJECT *) pictbridge -> ux_pictbridge_object_host;
else
object_info = (UX_SLAVE_CLASS_PIMA_OBJECT *) pictbridge -> ux_pictbridge_object_client;
/* Is this the correct handle ? */
if (object_info -> ux_device_class_pima_object_handle_id == object_handle)
{
/* Get the pointer to the object buffer. */
pima_object_buffer = object_info -> ux_device_class_pima_object_buffer;
/* Copy the demanded object data portion. */
_ux_utility_memory_copy(object_buffer, pima_object_buffer + object_offset, object_length_requested); /* Use case of memcpy is verified. */
/* Update the length requested. for a demo, we do not do any checking. */
*object_actual_length = object_length_requested;
/* What cycle are we in ? */
if (pictbridge -> ux_pictbridge_host_client_state_machine & UX_PICTBRIDGE_STATE_MACHINE_HOST_REQUEST)
{
/* Check if we are blocking for a client request. */
if (pictbridge -> ux_pictbridge_host_client_state_machine & UX_PICTBRIDGE_STATE_MACHINE_CLIENT_REQUEST_PENDING)
/* Yes we are pending, send an event to release the pending request. */
_ux_system_event_flags_set(&pictbridge -> ux_pictbridge_event_flags_group, UX_PICTBRIDGE_EVENT_FLAG_STATE_MACHINE_READY, UX_OR);
/* Since we are in host request, this indicates we are done with the cycle. */
pictbridge -> ux_pictbridge_host_client_state_machine = UX_PICTBRIDGE_STATE_MACHINE_IDLE;
}
/* We have copied the requested data. Return OK. */
return(UX_SUCCESS);
}
}
else
{
/* Obtain the data from the application jobinfo callback. */
status = pictbridge -> ux_pictbridge_jobinfo.ux_pictbridge_jobinfo_object_data_read(pictbridge, object_handle, object_buffer, object_offset,
object_length_requested, &actual_length);
/* Save the length returned. */
*object_actual_length = actual_length;
/* Return the application status. */
return(status);
}
/* Could not find the handle. */
return(UX_DEVICE_CLASS_PIMA_RC_INVALID_OBJECT_HANDLE);
}
|