Sam Ritter

Ranch Hand
+ Follow
since Jan 23, 2018
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sam Ritter

I have an application that plays audio clips as alerts. I select the mixer using:

Depending on the OS I may use a different mixer but the one I use does not matter to the problem. Once set 'useMixer' is referenced each time the code plays a clip. In my alert code I select the audio clip to be played thus:

Now for the problem. This code works just fine but only for a while. After playing several clips (I don't know if it is a fixed number or random) the code blows up with an error saying the mixer is not supported. Obviously that is a false error since that mixer worked fine previously. If I stop and relaunch the application the audio clips will once again play for a while.

The conclusion is that the mixer becomes somehow corrupted. The bottom line question is can the mixer be somehow reinitialized programmatically? I've spent hours trying to determine if and when the corruption occurs, if my conclusion is correct, to no avail so some kind of re-initialization is the most practical solution.
2 weeks ago
This is not really a Java question but I am trying to find someone with experience writing Java for a Pi that plays clips. I have determined that the default mixer (0) does not work so I had to select a different one (1).



Here is how I play clips:

This all works but only for a while. At some point when the app tries to play a clip (which it has before during the same run) I get an error telling me the mixer is not supported. The error is obviously dumb because the mixer worked for a while and only occurs on a Pi. Other *NIX work fine. If I end and restart the application then it will work again for a while. I have verified that it is always using the same mixer before and when it fails. Again this does not seem like a Java problem but rather a Pi problem but I don't know what to do to debug or fix it. Unfortunately there does not seem to be much Java expertise on the Pi forum that can help. TIA.
10 months ago
I found some code that is supposed to return the gateway address. However, when I run it, I get a traceback that makes no sense.

I'm getting an unknownhost exception but the traceback says addr is the wrong length. There is no such variable.


java.net.UnknownHostException: addr is of illegal length
at java.net.InetAddress.getByAddress(Unknown Source)
at java.net.InetAddress.getByAddress(Unknown Source)
at TestIfconfig.main(TestIfconfig.java:14)


Can someone tell me what is wrong or point me to a better way to get the gateway address? TIA.
When adding a new element the value might be a HashMap or some other Object, like just a string.
1 year ago
But here's the rub. Object will not always be Map but perhaps <> will still work.
1 year ago
Assuming I want to avoid dozens of warnings from my IDE about parameterizing raw types when casting, is there a symbolic way to avoid that.

It makes for redundant and hard to read code. TIA.
1 year ago
Thanks. It appears a linkedlist is a better approach.
I have a JSONObject that consists of 4 keys. Rather than access by key (which I don't necessarily know), I want to access by index. I found something in rpTools but I don't want to use a 3rd party library if I don't have to. Is there a native way to access JSON keys by index? TIA.

Tim Cooke wrote:Have you tried using this Java SDK from Maxim?

https://www.maximintegrated.com/en/products/ibutton-one-wire/one-wire/software-tools/api-java-sdk.html


Yes but when I try to download it crashed my machine. Today it seems to be working. Thanks.
1 year ago
I will be connecting 1-wire (yes I search both 1 and one) thermal sensors (DS18B20) to a Pi via USB adapters. I want to write a Java application that scans for multiple connected sensors and then monitors temperatures.
1 year ago
I am trying to learn about one wire devices and Java. Unfortunately I can't even get started. After lots of searching I can't find any documentation that describes the interfaces. Something as basic as how to scan for connected one wire devices is impossible (for me) to find. Can someone provide a link as a beginners guide to one wire programming in Java? TIA.
1 year ago
Thanks. ArrayDeque was previously unknown to to me so that looks like something I need to learn about.
1 year ago
I'm not sure what you mean by the index of Item21. I guess that is part of my question. How do I set that up to access that item? I am trying to emulate a piece of hardware that has 3 buttons and an LCD display to cycle through menus. The buttons would be up, down and select. The up button would go forward, say if Item2 were the current item then the up button would display Item3. The down button would display Item1. The select button would display Item21. From that point the same thing would happen with the up and down buttons with Item21, Item22, etc. There is a 4th button that reverts to the next higher level but I'm not worried about that once I get the right structure. This will be a fixed hierarchy of menu items 3 levels deep but the number of sub items under each upper item will not be the same.

My thoughts are to create a class and initialize the menu "array". Then have up, down and select methods that do the above. I'm just not sure how to structure the menu to accomplish the method functions.
1 year ago
I have a menu like structure that seems to be a tree to me. However, I will need to reference the structure by some index rather than key, although the key will be needed too. Here is the structure:

Main
  Item1
     Item11
     Item12
  Item2
     Item21
     Item22
     Item23
  Item3
     Item31
     Item32
.
.
.

I want to get the string (key) 'Item1' and know that is the current item. At some point I want to increment to get the next item string (key) 'Item2', etc. I only need to advance forward or backward one item at a time. That is I do not want to jump to random items. I would need to do the same with the second level if the current level is selected.

Is this a tree and if so how do I reference each item by index rather than key or iterate in order from the current item? If it is not a tree what is the best data type to accomplish this? TIA.
1 year ago
Sorry. I mis-typed the code in question. Line 25 is what I was really asking about. I am now pretty sure that was added by the de-compiler and is unnecessary.
1 year ago