]> sigrok.org Git - libsigrokdecode.git/blob - controller.c
srd: Remove manual log domain ("srd: ") prefixes.
[libsigrokdecode.git] / controller.c
1 /*
2  * This file is part of the sigrok project.
3  *
4  * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
5  * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include "sigrokdecode.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */
22 #include "sigrokdecode-internal.h"
23 #include "config.h"
24 #include <glib.h>
25 #include <inttypes.h>
26 #include <stdlib.h>
27
28
29 /* List of decoder instances. */
30 static GSList *di_list = NULL;
31
32 /* List of frontend callbacks to receive PD output. */
33 static GSList *callbacks = NULL;
34
35 /* lives in decoder.c */
36 extern GSList *pd_list;
37
38 /* lives in module_sigrokdecode.c */
39 extern PyMODINIT_FUNC PyInit_sigrokdecode(void);
40
41 /* lives in type_logic.c */
42 extern PyTypeObject srd_logic_type;
43
44
45 /**
46  * Initialize libsigrokdecode.
47  *
48  * This initializes the Python interpreter, and creates and initializes
49  * a "sigrok" Python module with a single put() method.
50  *
51  * Then, it searches for sigrok protocol decoder files (*.py) in the
52  * "decoders" subdirectory of the the sigrok installation directory.
53  * All decoders that are found are loaded into memory and added to an
54  * internal list of decoders, which can be queried via srd_list_decoders().
55  *
56  * The caller is responsible for calling the clean-up function srd_exit(),
57  * which will properly shut down libsigrokdecode and free its allocated memory.
58  *
59  * Multiple calls to srd_init(), without calling srd_exit() in between,
60  * are not allowed.
61  *
62  * @return SRD_OK upon success, a (negative) error code otherwise.
63  *         Upon Python errors, return SRD_ERR_PYTHON. If the sigrok decoders
64  *         directory cannot be accessed, return SRD_ERR_DECODERS_DIR.
65  *         If not enough memory could be allocated, return SRD_ERR_MALLOC.
66  */
67 int srd_init(void)
68 {
69         int ret;
70
71         srd_dbg("Initializing libsigrokdecode.");
72
73         /* Add our own module to the list of built-in modules. */
74         PyImport_AppendInittab("sigrokdecode", PyInit_sigrokdecode);
75
76         /* Initialize the python interpreter. */
77         Py_Initialize();
78
79         if ((ret = set_modulepath()) != SRD_OK) {
80                 Py_Finalize();
81                 return ret;
82         }
83
84         if ((ret = srd_load_all_decoders()) != SRD_OK) {
85                 Py_Finalize();
86                 return ret;
87         }
88
89         return SRD_OK;
90 }
91
92
93 /**
94  * Shutdown libsigrokdecode.
95  *
96  * This frees all the memory allocated for protocol decoders and shuts down
97  * the Python interpreter.
98  *
99  * This function should only be called if there was a (successful!) invocation
100  * of srd_init() before. Calling this function multiple times in a row, without
101  * any successful srd_init() calls in between, is not allowed.
102  *
103  * @return SRD_OK upon success, a (negative) error code otherwise.
104  */
105 int srd_exit(void)
106 {
107
108         srd_dbg("Exiting libsigrokdecode.");
109
110         srd_unload_all_decoders();
111         g_slist_free(pd_list);
112
113         /* Py_Finalize() returns void, any finalization errors are ignored. */
114         Py_Finalize();
115
116         return SRD_OK;
117 }
118
119
120 /**
121  * Add an additional search directory for the protocol decoders.
122  *
123  * The specified directory is prepended (not appended!) to Python's sys.path,
124  * in order to search for sigrok protocol decoders in the specified
125  * directories first, and in the generic Python module directories (and in
126  * the current working directory) last. This avoids conflicts if there are
127  * Python modules which have the same name as a sigrok protocol decoder in
128  * sys.path or in the current working directory.
129  *
130  * TODO: add path from env var SIGROKDECODE_PATH, config etc
131  * TODO: Should take directoryname/path as input.
132  *
133  * @return TODO.
134  */
135 int set_modulepath(void)
136 {
137         int ret;
138         gchar *path, *s;
139
140 #ifdef _WIN32
141         gchar **splitted;
142
143         /*
144          * On Windows/MinGW, Python's sys.path needs entries of the form
145          * 'C:\\foo\\bar' instead of '/foo/bar'.
146          */
147
148         splitted = g_strsplit(DECODERS_DIR, "/", 0);
149         path = g_build_pathv("\\\\", splitted);
150         g_strfreev(splitted);
151 #else
152         path = g_strdup(DECODERS_DIR);
153 #endif
154
155         /* TODO: Sanity check on 'path' (length, escape special chars, ...). */
156         s = g_strdup_printf("import sys; sys.path.insert(0, r'%s')", path);
157
158         ret = PyRun_SimpleString(s);
159
160         g_free(path);
161         g_free(s);
162
163         return ret;
164 }
165
166
167 /**
168  * Set options in a decoder instance.
169  *
170  * @param di Decoder instance.
171  * @param options A GHashTable of options to set.
172  *
173  * Handled options are removed from the hash.
174  *
175  * @return SRD_OK upon success, a (negative) error code otherwise.
176  */
177 int srd_instance_set_options(struct srd_decoder_instance *di,
178                 GHashTable *options)
179 {
180         PyObject *py_dec_options, *py_dec_optkeys, *py_di_options, *py_optval;
181         PyObject *py_optlist, *py_classval;
182         Py_UNICODE *py_ustr;
183         unsigned long long int val_ull;
184         int num_optkeys, ret, size, i;
185         char *key, *value;
186
187         if(!PyObject_HasAttrString(di->decoder->py_dec, "options")) {
188                 /* Decoder has no options. */
189                 if (g_hash_table_size(options) == 0) {
190                         /* No options provided. */
191                         return SRD_OK;
192                 } else {
193                         srd_err("Protocol decoder has no options.");
194                         return SRD_ERR_ARG;
195                 }
196                 return SRD_OK;
197         }
198
199         ret = SRD_ERR_PYTHON;
200         key = NULL;
201         py_dec_options = py_dec_optkeys = py_di_options = py_optval = NULL;
202         py_optlist = py_classval = NULL;
203         py_dec_options = PyObject_GetAttrString(di->decoder->py_dec, "options");
204
205         /* All of these are synthesized objects, so they're good. */
206         py_dec_optkeys = PyDict_Keys(py_dec_options);
207         num_optkeys = PyList_Size(py_dec_optkeys);
208         if (!(py_di_options = PyObject_GetAttrString(di->py_instance, "options")))
209                 goto err_out;
210         for (i = 0; i < num_optkeys; i++) {
211                 /* Get the default class value for this option. */
212                 py_str_as_str(PyList_GetItem(py_dec_optkeys, i), &key);
213                 if (!(py_optlist = PyDict_GetItemString(py_dec_options, key)))
214                         goto err_out;
215                 if (!(py_classval = PyList_GetItem(py_optlist, 1)))
216                         goto err_out;
217                 if (!PyUnicode_Check(py_classval) && !PyLong_Check(py_classval)) {
218                         srd_err("Options of type %s are not yet supported.", Py_TYPE(py_classval)->tp_name);
219                         goto err_out;
220                 }
221
222                 if ((value = g_hash_table_lookup(options, key))) {
223                         /* An override for this option was provided. */
224                         if (PyUnicode_Check(py_classval)) {
225                                 if (!(py_optval = PyUnicode_FromString(value))) {
226                                         /* Some UTF-8 encoding error. */
227                                         PyErr_Clear();
228                                         goto err_out;
229                                 }
230                         } else if (PyLong_Check(py_classval)) {
231                                 if (!(py_optval = PyLong_FromString(value, NULL, 0))) {
232                                         /* ValueError Exception */
233                                         PyErr_Clear();
234                                         srd_err("Option %s has invalid value %s: expected integer.",
235                                                         key, value);
236                                         goto err_out;
237                                 }
238                         }
239                         g_hash_table_remove(options, key);
240                 } else {
241                         /* Use the class default for this option. */
242                         if (PyUnicode_Check(py_classval)) {
243                                 /* Make a brand new copy of the string. */
244                                 py_ustr = PyUnicode_AS_UNICODE(py_classval);
245                                 size = PyUnicode_GET_SIZE(py_classval);
246                                 py_optval = PyUnicode_FromUnicode(py_ustr, size);
247                         } else if (PyLong_Check(py_classval)) {
248                                 /* Make a brand new copy of the integer. */
249                                 val_ull = PyLong_AsUnsignedLongLong(py_classval);
250                                 if (val_ull == (unsigned long long)-1) {
251                                         /* OverFlowError exception */
252                                         PyErr_Clear();
253                                         srd_err("Invalid integer value for %s: expected integer.", key);
254                                         goto err_out;
255                                 }
256                                 if (!(py_optval = PyLong_FromUnsignedLongLong(val_ull)))
257                                         goto err_out;
258                         }
259                 }
260
261                 /* If we got here, py_optval holds a known good new reference
262                  * to the instance option to set.
263                  */
264                 if (PyDict_SetItemString(py_di_options, key, py_optval) == -1)
265                         goto err_out;
266         }
267
268         ret = SRD_OK;
269
270 err_out:
271         Py_XDECREF(py_optlist);
272         Py_XDECREF(py_di_options);
273         Py_XDECREF(py_dec_optkeys);
274         Py_XDECREF(py_dec_options);
275         if (key)
276                 g_free(key);
277         if (PyErr_Occurred())
278                 catch_exception("Stray exception in srd_instance_set_options().");
279
280         return ret;
281 }
282
283 /* Helper GComparefunc for g_slist_find_custom() in srd_instance_set_probes() */
284 static gint compare_probe_id(struct srd_probe *a, char *probe_id)
285 {
286
287         return strcmp(a->id, probe_id);
288 }
289
290 /**
291  * Set probes in a decoder instance.
292  *
293  * @param di Decoder instance.
294  * @param probes A GHashTable of probes to set. Key is probe name, value is
295  * the probe number. Samples passed to this instance will be arranged in this
296  * order.
297  *
298  * @return SRD_OK upon success, a (negative) error code otherwise.
299  */
300 int srd_instance_set_probes(struct srd_decoder_instance *di,
301                 GHashTable *new_probes)
302 {
303         GList *l;
304         GSList *sl;
305         struct srd_probe *p;
306         int *new_probemap, new_probenum;
307         char *probe_id, *probenum_str;
308
309         if (g_hash_table_size(new_probes) == 0)
310                 /* No probes provided. */
311                 return SRD_OK;
312
313         if(di->dec_num_probes == 0) {
314                 /* Decoder has no probes. */
315                 srd_err("Protocol decoder %s has no probes to define.",
316                                 di->decoder->name);
317                 return SRD_ERR_ARG;
318         }
319
320         new_probemap = NULL;
321
322         if (!(new_probemap = g_try_malloc(sizeof(int) * di->dec_num_probes))) {
323                 srd_err("Failed to malloc new probe map.");
324                 return SRD_ERR_MALLOC;
325         }
326
327         for (l = g_hash_table_get_keys(new_probes); l; l = l->next) {
328                 probe_id = l->data;
329                 probenum_str = g_hash_table_lookup(new_probes, probe_id);
330                 if (!probenum_str) {
331                         /* Probe name was specified without a value. */
332                         srd_err("No probe number was specified for %s.", probe_id);
333                         g_free(new_probemap);
334                         return SRD_ERR_ARG;
335                 }
336                 new_probenum = strtol(probenum_str, NULL, 10);
337                 if (!(sl = g_slist_find_custom(di->decoder->probes, probe_id,
338                                 (GCompareFunc)compare_probe_id))) {
339                         /* Fall back on optional probes. */
340                         if (!(sl = g_slist_find_custom(di->decoder->extra_probes,
341                                         probe_id, (GCompareFunc)compare_probe_id))) {
342                                 srd_err("Protocol decoder %s has no probe '%s'.",
343                                                 di->decoder->name, probe_id);
344                                 g_free(new_probemap);
345                                 return SRD_ERR_ARG;
346                         }
347                 }
348                 p = sl->data;
349                 new_probemap[p->order] = new_probenum;
350         }
351         g_free(di->dec_probemap);
352         di->dec_probemap = new_probemap;
353
354         return SRD_OK;
355 }
356
357 /**
358  * Create a new protocol decoder instance.
359  *
360  * @param id Decoder 'id' field.
361  * @param options GHashtable of options which override the defaults set in
362  *          the decoder class.
363  * @return Pointer to a newly allocated struct srd_decoder_instance, or
364  *              NULL in case of failure.
365  */
366 struct srd_decoder_instance *srd_instance_new(const char *decoder_id,
367                 GHashTable *options)
368 {
369         struct srd_decoder *dec;
370         struct srd_decoder_instance *di;
371         int i;
372         char *instance_id;
373
374         srd_dbg("Creating new %s instance.", decoder_id);
375
376         if (!(dec = srd_get_decoder_by_id(decoder_id))) {
377                 srd_err("Protocol decoder %s not found.", decoder_id);
378                 return NULL;
379         }
380
381         if (!(di = g_try_malloc0(sizeof(*di)))) {
382                 srd_err("Failed to malloc instance.");
383                 return NULL;
384         }
385
386         instance_id = g_hash_table_lookup(options, "id");
387         di->decoder = dec;
388         di->instance_id = g_strdup(instance_id ? instance_id : decoder_id);
389         g_hash_table_remove(options, "id");
390
391         /* Prepare a default probe map, where samples come in the
392          * order in which the decoder class defined them.
393          */
394         di->dec_num_probes = g_slist_length(di->decoder->probes) +
395                         g_slist_length(di->decoder->extra_probes);
396         if (di->dec_num_probes) {
397                 if (!(di->dec_probemap = g_try_malloc(sizeof(int) * di->dec_num_probes))) {
398                         srd_err("Failed to malloc probe map.");
399                         g_free(di);
400                         return NULL;
401                 }
402                 for (i = 0; i < di->dec_num_probes; i++)
403                         di->dec_probemap[i] = i;
404         }
405
406         /* Create a new instance of this decoder class. */
407         if (!(di->py_instance = PyObject_CallObject(dec->py_dec, NULL))) {
408                 if (PyErr_Occurred())
409                         catch_exception("failed to create %s instance: ", decoder_id);
410                 g_free(di->dec_probemap);
411                 g_free(di);
412                 return NULL;
413         }
414
415         if (srd_instance_set_options(di, options) != SRD_OK) {
416                 g_free(di->dec_probemap);
417                 g_free(di);
418                 return NULL;
419         }
420
421         /* Instance takes input from a frontend by default. */
422         di_list = g_slist_append(di_list, di);
423
424         return di;
425 }
426
427 int srd_instance_stack(struct srd_decoder_instance *di_from,
428                 struct srd_decoder_instance *di_to)
429 {
430
431         if (!di_from || !di_to) {
432                 srd_err("Invalid from/to instance pair.");
433                 return SRD_ERR_ARG;
434         }
435
436         if (g_slist_find(di_list, di_to)) {
437                 /* Remove from the unstacked list. */
438                 di_list = g_slist_remove(di_list, di_to);
439         }
440
441         /* Stack on top of source di. */
442         di_from->next_di = g_slist_append(di_from->next_di, di_to);
443
444         return SRD_OK;
445 }
446
447 /**
448  * Finds a decoder instance by its instance id, but only in the bottom
449  * level of instances -- instances already stacked on top of another one
450  * will not be found.
451  *
452  * @param instance_id The instance id to be found.
453  *
454  * @return Pointer to struct srd_decoder_instance, or NULL if not found.
455  */
456 struct srd_decoder_instance *srd_instance_find_by_id(char *instance_id)
457 {
458         GSList *l;
459         struct srd_decoder_instance *tmp, *di;
460
461         di = NULL;
462         for (l = di_list; l; l = l->next) {
463                 tmp = l->data;
464                 if (!strcmp(tmp->instance_id, instance_id)) {
465                         di = tmp;
466                         break;
467                 }
468         }
469
470         return di;
471 }
472
473 /**
474  * Finds a decoder instance by its python object, i.e. that instance's
475  * instantiation of the sigrokdecode.Decoder class. This will recurse
476  * to find the instance anywhere in the stack tree.
477  *
478  * @param stack Pointer to a GSList of struct srd_decoder_instance,
479  *              indicating the stack to search. To start searching at the bottom
480  *              level of decoder instances, pass NULL.
481  * @param obj The python class instantiation.
482  *
483  * @return Pointer to struct srd_decoder_instance, or NULL if not found.
484  */
485 struct srd_decoder_instance *srd_instance_find_by_obj(GSList *stack,
486                 PyObject *obj)
487 {
488         GSList *l;
489         struct srd_decoder_instance *tmp, *di;
490
491         di = NULL;
492         for (l = stack ? stack : di_list; di == NULL && l != NULL; l = l->next) {
493                 tmp = l->data;
494                 if (tmp->py_instance == obj)
495                         di = tmp;
496                 else if (tmp->next_di)
497                         di = srd_instance_find_by_obj(tmp->next_di, obj);
498         }
499
500         return di;
501 }
502
503 int srd_instance_start(struct srd_decoder_instance *di, PyObject *args)
504 {
505         PyObject *py_name, *py_res;
506         GSList *l;
507         struct srd_decoder_instance *next_di;
508
509         srd_dbg("Calling start() method on protocol decoder instance %s.",
510                 di->instance_id);
511
512         if (!(py_name = PyUnicode_FromString("start"))) {
513                 srd_err("Unable to build python object for 'start'.");
514                 catch_exception("Protocol decoder instance %s: ", di->instance_id);
515                 return SRD_ERR_PYTHON;
516         }
517
518         if (!(py_res = PyObject_CallMethodObjArgs(di->py_instance,
519                         py_name, args, NULL))) {
520                 catch_exception("Protocol decoder instance %s: ", di->instance_id);
521                 return SRD_ERR_PYTHON;
522         }
523
524         Py_DecRef(py_res);
525         Py_DecRef(py_name);
526
527         /* Start all the PDs stacked on top of this one. Pass along the
528          * metadata all the way from the bottom PD, even though it's only
529          * applicable to logic data for now.
530          */
531         for (l = di->next_di; l; l = l->next) {
532                 next_di = l->data;
533                 srd_instance_start(next_di, args);
534         }
535
536         return SRD_OK;
537 }
538
539 /**
540  * Run the specified decoder function.
541  *
542  * @param start_samplenum The starting sample number for the buffer's sample
543  *                        set, relative to the start of capture.
544  * @param di The decoder instance to call. Must not be NULL.
545  * @param inbuf The buffer to decode. Must not be NULL.
546  * @param inbuflen Length of the buffer. Must be > 0.
547  *
548  * @return SRD_OK upon success, a (negative) error code otherwise.
549  */
550 int srd_instance_decode(uint64_t start_samplenum,
551         struct srd_decoder_instance *di, uint8_t *inbuf, uint64_t inbuflen)
552 {
553         PyObject *py_res;
554         srd_logic *logic;
555         uint64_t end_samplenum;
556
557         srd_dbg("Calling decode() on instance %s with %d bytes starting "
558                 "at sample %d.", di->instance_id, inbuflen, start_samplenum);
559
560         /* Return an error upon unusable input. */
561         if (!di) {
562                 srd_dbg("empty decoder instance");
563                 return SRD_ERR_ARG;
564         }
565         if (!inbuf) {
566                 srd_dbg("NULL buffer pointer");
567                 return SRD_ERR_ARG;
568         }
569         if (inbuflen == 0) {
570                 srd_dbg("empty buffer");
571                 return SRD_ERR_ARG;
572         }
573
574         /* Create new srd_logic object. Each iteration around the PD's loop
575          * will fill one sample into this object.
576          */
577         logic = PyObject_New(srd_logic, &srd_logic_type);
578         Py_INCREF(logic);
579         logic->di = di;
580         logic->start_samplenum = start_samplenum;
581         logic->itercnt = 0;
582         logic->inbuf = inbuf;
583         logic->inbuflen = inbuflen;
584         logic->sample = PyList_New(2);
585         Py_INCREF(logic->sample);
586
587         Py_IncRef(di->py_instance);
588         end_samplenum = start_samplenum + inbuflen / di->data_unitsize;
589         if (!(py_res = PyObject_CallMethod(di->py_instance, "decode",
590                         "KKO", logic->start_samplenum, end_samplenum, logic))) {
591                 catch_exception("Protocol decoder instance %s: ", di->instance_id);
592                 return SRD_ERR_PYTHON; /* TODO: More specific error? */
593         }
594         Py_DecRef(py_res);
595
596         return SRD_OK;
597 }
598
599
600 int srd_session_start(int num_probes, int unitsize, uint64_t samplerate)
601 {
602         PyObject *args;
603         GSList *d;
604         struct srd_decoder_instance *di;
605         int ret;
606
607         srd_dbg("Calling start() on all instances with %d probes, "
608                 "unitsize %d samplerate %d.", num_probes, unitsize, samplerate);
609
610         /* Currently only one item of metadata is passed along to decoders,
611          * samplerate. This can be extended as needed.
612          */
613         if (!(args = Py_BuildValue("{s:l}", "samplerate", (long)samplerate))) {
614                 srd_err("Unable to build python object for metadata.");
615                 return SRD_ERR_PYTHON;
616         }
617
618         /* Run the start() method on all decoders receiving frontend data. */
619         for (d = di_list; d; d = d->next) {
620                 di = d->data;
621                 di->data_num_probes = num_probes;
622                 di->data_unitsize = unitsize;
623                 di->data_samplerate = samplerate;
624                 if ((ret = srd_instance_start(di, args) != SRD_OK))
625                         break;
626         }
627
628         Py_DecRef(args);
629
630         return ret;
631 }
632
633 /* Feed logic samples to decoder session. */
634 int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf, uint64_t inbuflen)
635 {
636         GSList *d;
637         int ret;
638
639         srd_dbg("Calling decode() on all instances with starting sample "
640                 "number %"PRIu64", %"PRIu64" bytes at 0x%p", start_samplenum,
641                 inbuflen, inbuf);
642
643         for (d = di_list; d; d = d->next) {
644                 if ((ret = srd_instance_decode(start_samplenum, d->data, inbuf,
645                                 inbuflen)) != SRD_OK)
646                         return ret;
647         }
648
649         return SRD_OK;
650 }
651
652
653 int srd_register_callback(int output_type, void *cb)
654 {
655         struct srd_pd_callback *pd_cb;
656
657         srd_dbg("Registering new callback for output type %d.", output_type);
658
659         if (!(pd_cb = g_try_malloc(sizeof(struct srd_pd_callback))))
660                 return SRD_ERR_MALLOC;
661
662         pd_cb->output_type = output_type;
663         pd_cb->callback = cb;
664         callbacks = g_slist_append(callbacks, pd_cb);
665
666         return SRD_OK;
667 }
668
669 void *srd_find_callback(int output_type)
670 {
671         GSList *l;
672         struct srd_pd_callback *pd_cb;
673         void *(cb);
674
675         cb = NULL;
676         for (l = callbacks; l; l = l->next) {
677                 pd_cb = l->data;
678                 if (pd_cb->output_type == output_type) {
679                         cb = pd_cb->callback;
680                         break;
681                 }
682         }
683
684         return cb;
685 }
686
687
688 /* This is the backend function to python sigrokdecode.add() call. */
689 int pd_add(struct srd_decoder_instance *di, int output_type, char *proto_id)
690 {
691         struct srd_pd_output *pdo;
692
693         srd_dbg("Instance %s creating new output type %d for %s.",
694                 di->instance_id, output_type, proto_id);
695
696         if (!(pdo = g_try_malloc(sizeof(struct srd_pd_output))))
697                 return -1;
698
699         /* pdo_id is just a simple index, nothing is deleted from this list anyway. */
700         pdo->pdo_id = g_slist_length(di->pd_output);
701         pdo->output_type = output_type;
702         pdo->di = di;
703         pdo->proto_id = g_strdup(proto_id);
704         di->pd_output = g_slist_append(di->pd_output, pdo);
705
706         return pdo->pdo_id;
707 }
708