ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I run MythTV on my HTPC, and my recording device is an R5000. For years I've had to patch MythTV and compile to work with the R5000, but as time's passed the patch developer is gone, the maker of the R5000 is gone, and I am left to try and keep this thing going with new versions of Myth.
I have adapted the patch to Myth0.27 and it compiles cleanly. But when I start the Myth backend (server) I get this:
Code:
2013-02-27 16:06:31.572980 C [13987/13987] thread_unknown mythcommandlineparser.cpp:2572 (ConfigureLogging) - mythbackend version: master [v0.27-pre2-534-g47a2da4-dirty] www.mythtv.org
2013-02-27 16:06:31.573033 C [13987/13987] thread_unknown mythcommandlineparser.cpp:2574 (ConfigureLogging) - Qt version: compile: 4.8.2, runtime: 4.8.2
2013-02-27 16:06:31.573041 N [13987/13987] thread_unknown mythcommandlineparser.cpp:2576 (ConfigureLogging) - Enabled verbose msgs: general
2013-02-27 16:06:31.573217 N [13987/13987] thread_unknown logging.cpp:852 (logStart) - Setting Log Level to LOG_INFO
2013-02-27 16:06:31.574229 I [13987/13987] thread_unknown signalhandling.cpp:194 (SetHandlerPrivate) - Setup Interrupt handler
2013-02-27 16:06:31.574240 I [13987/13987] thread_unknown signalhandling.cpp:194 (SetHandlerPrivate) - Setup Terminated handler
2013-02-27 16:06:31.574251 I [13987/13987] thread_unknown signalhandling.cpp:194 (SetHandlerPrivate) - Setup Segmentation fault handler
2013-02-27 16:06:31.574260 I [13987/13987] thread_unknown signalhandling.cpp:194 (SetHandlerPrivate) - Setup Aborted handler
2013-02-27 16:06:31.574268 I [13987/13987] thread_unknown signalhandling.cpp:194 (SetHandlerPrivate) - Setup Bus error handler
2013-02-27 16:06:31.574278 I [13987/13987] thread_unknown signalhandling.cpp:194 (SetHandlerPrivate) - Setup Floating point exception handler
2013-02-27 16:06:31.574286 I [13987/13987] thread_unknown signalhandling.cpp:194 (SetHandlerPrivate) - Setup Illegal instruction handler
2013-02-27 16:06:31.574297 I [13987/13987] thread_unknown signalhandling.cpp:194 (SetHandlerPrivate) - Setup Real-time signal 0 handler
2013-02-27 16:06:31.574368 N [13987/13987] thread_unknown mythdirs.cpp:55 (InitializeMythDirs) - Using runtime prefix = /usr/local
2013-02-27 16:06:31.574384 N [13987/13987] thread_unknown mythdirs.cpp:68 (InitializeMythDirs) - Using configuration directory = /home/mythtv/.mythtv
2013-02-27 16:06:31.574525 I [13987/13987] CoreContext mythcorecontext.cpp:238 (Init) - Assumed character encoding: en_US.UTF-8
2013-02-27 16:06:31.574729 I [13987/13988] Logger logging.cpp:307 (run) - Added logging to the console
2013-02-27 16:06:31.575224 N [13987/13987] CoreContext mythcontext.cpp:486 (LoadDatabaseSettings) - Empty LocalHostName.
2013-02-27 16:06:31.575239 I [13987/13987] CoreContext mythcontext.cpp:494 (LoadDatabaseSettings) - Using localhost value of cygnus
2013-02-27 16:06:31.588405 N [13987/13987] CoreContext mythcorecontext.cpp:1291 (InitLocale) - Setting QT default locale to EN_US
2013-02-27 16:06:31.588517 I [13987/13987] CoreContext mythcorecontext.cpp:1324 (SaveLocaleDefaults) - Current locale EN_US
2013-02-27 16:06:31.588570 N [13987/13987] CoreContext mythlocale.cpp:121 (LoadDefaultsFromXML) - Reading locale defaults from /usr/local/share/mythtv//locales/en_us.xml
2013-02-27 16:06:31.592622 I [13987/13987] CoreContext schemawizard.cpp:118 (Compare) - Current MythTV Schema Version (DBSchemaVer): 1310
2013-02-27 16:06:31.592930 I [13987/13987] CoreContext mythtranslation.cpp:65 (load) - Loading en_us translation for module mythfrontend
2013-02-27 16:06:31.593241 N [13987/13987] CoreContext main_helpers.cpp:572 (run_backend) - MythBackend: Starting up as the master server.
2013-02-27 16:06:31.799122 I [13987/13988] Logger logging.cpp:488 (launchLogServer) - Starting mythlogserver
2013-02-27 16:06:31.799292 I [13987/13995] SystemManager system-unix.cpp:263 (run) - Starting process manager
2013-02-27 16:06:31.799550 I [13987/13999] SystemSignalManager system-unix.cpp:490 (run) - Starting process signal handler
2013-02-27 16:06:31.799587 I [13987/14001] SystemIOHandlerW system-unix.cpp:90 (run) - Starting IO manager (write)
2013-02-27 16:06:31.801659 I [13987/14000] SystemIOHandlerR system-unix.cpp:90 (run) - Starting IO manager (read)
2013-02-27 16:06:31.909140 I [13987/13987] CoreContext r5000device.cpp:46 (r5000_msg) - R5kDev: R5kLib: R5000 initialization failed at stage 1:
Expected 1 bytes, but got -16 bytes
2013-02-27 16:06:31.909379 I [13987/13987] CoreContext r5000device.cpp:46 (r5000_msg) - R5kDev: R5kLib: R5000 failed to locate any R5000 devices. Are you sure you have permissions set properly?
2013-02-27 16:06:31.953152 I [13987/13987] CoreContext r5000device.cpp:46 (r5000_msg) - R5kDev: R5kLib: R5000 was not initialized before r5000_open(). Please call r5000_init() first
2013-02-27 16:06:31.953164 E [13987/13987] CoreContext recorders/channelbase.cpp:1235 (CreateChannel) - ChannelBase: CreateChannel() Error: Failed to open device 100563E
2013-02-27 16:06:31.954221 E [13987/13987] CoreContext main_helpers.cpp:198 (setupTVs) - Problem with capture cardsCard 5failed init
2013-02-27 16:06:31.999891 I [13987/13988] Logger logging.cpp:448 (initialTimeout) - Added logging to mythlogserver at TCP:35327
2013-02-27 16:06:32.025931 I [13987/13987] CoreContext programinfo.cpp:2114 (CheckProgramIDAuthorities) - Found 1 distinct programid authorities
2013-02-27 16:06:32.027977 I [13987/14025] Scheduler mythdbcon.cpp:436 (getStaticCon) - New static DB connectionSchedCon
2013-02-27 16:06:32.028785 I [13987/13987] CoreContext serverpool.cpp:395 (listen) - Listening on TCP 127.0.0.1:6544
2013-02-27 16:06:32.029821 N [13987/13987] CoreContext mediaserver.cpp:169 (Init) - MediaServer:: Loopback address specified - 127.0.0.1. Disabling UPnP
2013-02-27 16:06:32.029826 I [13987/13987] CoreContext main_helpers.cpp:642 (run_backend) - Main::Registering HttpStatus Extension
2013-02-27 16:06:32.030670 W [13987/13987] CoreContext mainserver.cpp:262 (MainServer) - Unable to find IPv6 address to bind
2013-02-27 16:06:32.030716 I [13987/13987] CoreContext serverpool.cpp:395 (listen) - Listening on TCP 127.0.0.1:6543
2013-02-27 16:06:32.032032 N [13987/13987] CoreContext autoexpire.cpp:264 (CalcParams) - AutoExpire: CalcParams(): Max required Free Space: 1.0 GB w/freq: 15 min
2013-02-27 16:06:35.033545 I [13987/14025] Scheduler scheduler.cpp:2088 (HandleReschedule) - Reschedule requested for MATCH 0 0 0 - SchedulerInit
I am not a coding genius, but it looks like the r5000 is not being init-ed before opened. I just don't know what to do about it. It's definitely not a permissions problem.
The error calles out the r5000device.cpp file, which is here.
Can anyone see what might be wrong here?
Last edited by Quantumstate; 02-27-2013 at 06:19 PM.
based on the error message probably you missed a call: R5000 was not initialized before r5000_open(). Please call r5000_init() first
the source file does not help, r5000device.cpp:46 is a simple logger function
I find r5000_open() in libs/libmythtv/r5000/r5000.c, but it only has the error message:
"R5000 was not initialized before r5000_open(). Please call r5000_init() first\n"
I find r5000_open( in three places:
libs/libmythtv/r5000device.cpp starting line 289
Code:
bool R5000Device::OpenPort(void)
{
LOG(VB_RECORD, LOG_DEBUG, LOC + "Starting Port Handler Thread");
QMutexLocker mlocker(&m_lock);
LOG(VB_RECORD, LOG_DEBUG, LOC + "Starting Port Handler Thread -- locked");
if (usbdev)
{
m_open_port_cnt++;
return true;
}
if (m_serial.length())
{
LOG(VB_RECORD, LOG_DEBUG, LOC + QString("Opening R5000 device type %1 with serial#: "+ m_serial).arg(m_type));
usbdev = r5000_open((r5ktype_t)m_type, r5000_device_tspacket_handler, this, m_serial.toAscii().constData());
}
else
{
LOG(VB_RECORD, LOG_DEBUG, LOC + "Opening R5000 device with unknown serial#");
usbdev = r5000_open((r5ktype_t)m_type, r5000_device_tspacket_handler, this, NULL);
}
if (! usbdev)
{
LOG(VB_GENERAL, LOG_DEBUG, LOC + "Failed to open R5000 device");
return false;
}
LOG(VB_RECORD, LOG_DEBUG, LOC + "Starting port handler thread");
m_priv->run_port_handler = true;
pthread_create(&m_priv->port_handler_thread, NULL,
r5000_device_port_handler_thunk, this);
LOG(VB_RECORD, LOG_DEBUG, LOC + "Waiting for port handler thread to start");
while (!m_priv->is_port_handler_running)
{
m_lock.unlock();
usleep(5000);
m_lock.lock();
}
LOG(VB_RECORD, LOG_DEBUG, LOC + "Port handler thread started");
m_open_port_cnt++;
return true;
}
In libs/libmythtv/r5000/r5000.c starting line 341:
And in libs/libmythtv/r5000/r5000.h starting line 40:
Code:
extern int r5000_init(void (*_msgcb)(char *str));
extern r5kdev_t *r5000_open(r5ktype_t type, unsigned int (*cb)(unsigned char *buffer, int len, void *callback_data), void *cb_data, const char *serial);
extern int r5000_close(r5kdev_t *r5kdev);
I find r5000_init( in the same three files, starting with libs/libmyth/r5000device.cpp on line 81 then 408:
Code:
R5000Device::R5000Device(int type, QString serial) :
m_type(type),
m_serial(serial),
m_last_channel(""), m_last_crc(0),
m_buffer_cleared(true), m_open_port_cnt(0),
m_lock(), m_priv(new R5kPriv())
{
QMutexLocker locker(&s_static_lock);
usbdev = NULL;
if (! r5k_init)
r5k_init = r5000_init(r5000_msg);
}
...
QStringList R5000Device::GetSTBList(void)
{
QStringList STBList;
int i;
r5kenum_t r5k_stbs;
if (! r5k_init)
{
r5k_init = r5000_init(r5000_msg);
if (! r5k_init)
return STBList;
}
if (! r5000_find_stbs(&r5k_stbs))
LOG(VB_GENERAL, LOG_DEBUG, LOC + "Locating R5000 devices failed."
" This may be a permission problem");
for (i = 0; i < r5k_stbs.count; i++)
STBList.append((char *)r5k_stbs.serial[i]);
return STBList;
}
Then libs/libmythth/r5000/r5000.c on line 301 (The error is here):
Code:
/* r5000_init must be called from a thread-safe context */
int r5000_init(void (*_msgcb)(char *str))
{
int bus_count, dev_count;
r5kdev_t r5kd;
int count = 0;
r5000_log(0, "r5000_init()");
msgcb = _msgcb;
if(r5000_usb_init)
return 1;
usb_init();
bus_count = usb_find_busses();
dev_count = usb_find_devices();
if(bus_count == 0 || dev_count ==0) {
r5000_print("R5000 failed to locate any USB devices. Are you sure you have permissions set properly?\n");
return 0;
}
And then libs/mibmythtv/r5000/r5000.h line 40:
Code:
extern int r5000_init(void (*_msgcb)(char *str));
extern r5kdev_t *r5000_open(r5ktype_t type, unsigned int (*cb)(unsigned char *buffer, int len, void *callback_data), void *cb_data, const char *serial);
extern int r5000_close(r5kdev_t *r5kdev);
extern int r5000_start_stream(r5kdev_t *r5kdev);
Well I've done a diff between r5000.c from an old Myth 0.24 that worked, and the one I have now for 0.27, and they are binary equal so that can't be where the problem is. Same with r5000.h
I did a diff between the old and new r5000device.cpp's, and the only differences were changes to logging.
2013-02-27 16:06:31.909140 I [13987/13987] CoreContext r5000device.cpp:46 (r5000_msg) - R5kDev: R5kLib: R5000 initialization failed at stage 1:
Expected 1 bytes, but got -16 bytes
The "-16 bytes" is probably 'usb_bulk_read' (I couldn't find the source to this function, so this is a bit of a guess) returning -EBUSY (Device or resource busy). Is it possible that the device is already in use by something else (another part of mythtv possibly?).
Ho-ly cow. After I finished the test you suggested, I cleared all the directories and moved the MySQL libs to wind everything back to Myth 0.24 (so I could at least watch TV), but to my horror I found that 0.24 was now giving the same error as 0.27!
Majorly clue.
You said the device might be busy. Apparently it's errored. So I put everything back to 0.27, powered down everything, restarted and now 0.27 works!
I have a feeling though, if -anything- goes wrong the r5000 interface card may error again. At least now I have a sense that I can fix it. See it's an addon card inside the Dish Network satellite box, which taps into the guts to suck out the unencrypted transport stream. The r5000 gets its power from USB, so powering down the Dish box is not enough; must unplug the r5000 USB as well or power down the computer. When I did a cold shutdown, everything came up, but when I restart the backend it fails. Apparently the backend is not initializing the card like it should.
I've been following this thread, but I'm a litle unclear as to what you're saying ultimately, at this point. In this:
Quote:
Originally Posted by Quantumstate
...I put everything back to 0.27, powered down everything, restarted and now 0.27 works!...
you seem to say that everything worked. But then in the the below, to me, it's as if you're going on to say that it really didn't work:
Quote:
Originally Posted by Quantumstate
...I have a feeling though, if -anything- goes wrong the r5000 interface card may error again. At least now I have a sense that I can fix it. See it's an addon card inside the Dish Network satellite box, which taps into the guts to suck out the unencrypted transport stream. The r5000 gets its power from USB, so powering down the Dish box is not enough; must unplug the r5000 USB as well or power down the computer. When I did a cold shutdown, everything came up, but when I restart the backend it fails. Apparently the backend is not initializing the card like it should...
OR, are you saying that a cold shutdown of everything works, but some type of "warm re-start" of the "backend" doesn't init the card? If so, how exactly do you do that "warm re-start" of the "backend"?
If things don't fully work on a cold start, then please provide more details.
Just some general observations:
1) It sounds as if the r5000 interface card could be considered a so called "embedded" application.
2) Often that's a specialized use of what is virtually a general purpose computer, in some sense.
3) If 1 & 2 above are true, it may be that:
a) the card should be getting a so called "init" pulse from a buss/backplane, if any, into which it may be plugged, but it is not actually getting that pulse, or...
b) the card might not be responding correctly to the "init pulse".
If you are actually saying that if you "cold start" everything, it really does work, then if you are not satisfied with that, you might be looking at delving into the structure of the buss/backplane, if any, to see if there is an "init" pulse the card should be re-acting to, and/or looking at the hardware or firmware on the card, if you are in a position to do either of those. Sometimes the hardware should react to an "init" pulse, sometimes the firmware is also involved.
I'm saying that it seemed to work, as I am no longer getting the failure to recognize the r5000 when I start the backend. This happened because I've learned to do a cold start of the hardware. Before, when I simply restarted the Myth backend and the r5000 was errored, it would never recover. It appears that the backend is not sending a true init to the r5000.
I can live with that. But now I find that it is not actually recording. The backend is going through all the motions, and seems to think it's recording shows, but the mpg files end up with zero bytes. Normally they'd be 1 or 2GB files. The backend doesn't flag any errors in the log file. What I see is this:
Code:
]Scheduler autoexpire.cpp:264 (CalcParams) - AutoExpire: CalcParams(): Max required Free Space: 3.0 GB w/freq: 14 min
Scheduler scheduler.cpp:2658 (HandleRecordingStatusChange) - Started recording: "Tech Toys 360": channel 2364 on cardid 5, sourceid 2
ProcessRequest mainserver.cpp:1429 (HandleAnnounce) - MainServer::ANN Monitor
ProcessRequest mainserver.cpp:1431 (HandleAnnounce) - adding: cygnus as a client (events: 0)
ProcessRequest mainserver.cpp:1429 (HandleAnnounce) - MainServer::ANN Monitor
ProcessRequest mainserver.cpp:1431 (HandleAnnounce) - adding: cygnus as a client (events: 1)
PreviewGenerator previewgenerator.cpp:266 (Run) - Preview: Encountered problems running '/usr/local/bin/mythpreviewgen' (128)
Commflag_9273 jobqueue.cpp:2281 (DoFlagCommercialsThread) - JobQueue: Commercial Detection Starting for "Tech Toys 360" recorded from channel 2364 at 2013-03-04T12:30:00Z
ProcessRequest mainserver.cpp:1429 (HandleAnnounce) - MainServer::ANN Monitor
ProcessRequest mainserver.cpp:1431 (HandleAnnounce) - adding: cygnus as a client (events: 0)
ProcessRequest mainserver.cpp:1429 (HandleAnnounce) - MainServer::ANN Monitor
ProcessRequest mainserver.cpp:1431 (HandleAnnounce) - adding: cygnus as a client (events: 1)
Commflag_9273 previewgenerator.cpp:266 (Run) - Preview: Encountered problems running '/usr/local/bin/mythpreviewgen' (128)
TVRecEvent tv_rec.cpp:1044 (HandleStateChange) - TVRec[5]: Changing from RecordingOnly to None
thread_unknown r5000device.cpp:46 (r5000_msg) - R5kDev: R5kLib: (6) Reap failed at b3e98000: Success
TVRecEvent recordinginfo.cpp:1068 (FinishedRecording) - Finished recording Tech Toys 360 "Pagani Huayra; Looxcie Personal Video Camera": channel 2364
CoreContext scheduler.cpp:698 (UpdateRecStatus) - Updating status for "Tech Toys 360":"Pagani Huayra; Looxcie Personal Video Camera" on cardid 5 (Recording => Recorded)
Scheduler scheduler.cpp:2138 (HandleReschedule) - Reschedule requested for CHECK -3 2275 0 UpdateRecStatus2 | Tech Toys 360 | Pagani Huayra; Looxcie Personal Video Camera | Pagani Huayra sports car; Looxcie personal video camera. | EP014731110010
Scheduler scheduler.cpp:2242 (HandleReschedule) - Reschedule interrupted, will retry
Scheduler scheduler.cpp:2138 (HandleReschedule) - Reschedule requested for PLACE Interrupted
Scheduler scheduler.cpp:2251 (HandleReschedule) - Scheduled 697 items in 0.2 = 0.00 match + 0.00 check + 0.16 place
It's no surprise that preview generation and commercial flagging failed, as the file is empty, but the weird thing is that "thread_unknown r5000device.cpp:46" message. I don't really understand that.
It seems the backend is waiting dutifully while the r5000 is supposed to be sending video. I know that it's changing the channel of the Dish box, as I watched it do that last night, so permissions are good and it's able to control. Only thing is the video is not squirting out for some reason. It definitely worked yesterday running Myth version 0.24.
Could this again indicate that the backend is not doing a proper init of the r5000?
There is a way to make r5ktest get video samples. I'll try to figure that out.
Last edited by Quantumstate; 03-04-2013 at 09:49 AM.
Well r5ktest got a zero-sized file as well when I tried to pull video.
I've found that rather than doing a cold shutdown, restarting udev makes the r5000 available again. I didn't try a udev restart then r5ktest, as I am quite sick of having spent days on this and having no TV for over a week. For now I'm back on Myth 0.24 and it seems to be recording.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.