Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

Mr Shiny Pants posted:

Sounds like you need a queue.

No, that's not what I meant by specific order. I want to be able to dictate that for every set of mutations on the database, the order will always, without exception, be the same (e.g. Table1, then table2, then table3, never table2, then table 1 etc.)

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Jewel posted:

Oh jeez, I forgot this was so soon. My plan this year was to learn F# or Rust, I'm not mentally prepared yet :negative:

https://learnxinyminutes.com/docs/rust/
https://learnxinyminutes.com/docs/fsharp/

Jewel
May 2, 2009


Ty for these! I more meant I'm in the process of studying/learning another non-programming thing right now and don't have the mental capacity for both at once but this will help when I come back around to it!

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

Jewel posted:

Ty for these! I more meant I'm in the process of studying/learning another non-programming thing right now and don't have the mental capacity for both at once but this will help when I come back around to it!

If you know C#, you're already an F# dev, you just don't realize it yet.

Jewel
May 2, 2009

Cuntpunch posted:

If you know C#, you're already an F# dev, you just don't realize it yet.

That was pretty much my mindset, like, "I abused the hell out of Linq during the other years' AoC, why not just go full-throttle" but I'm worried full-functional is gonna be rough for every situation, which is why rust was the other option.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Jewel posted:

That was pretty much my mindset, like, "I abused the hell out of Linq during the other years' AoC, why not just go full-throttle" but I'm worried full-functional is gonna be rough for every situation, which is why rust was the other option.

F# is pretty flexible, there's a lot of OO-style stuff in there if you want to use it - you can do everything with classes and methods and mutable variables if you really want. So you might find moments where the functional approach is a bit tough, and you can dip into the OO side of things to smooth it over

Here's a couple of links if you're interested!
13 ways of looking at a turtle - maybe you only wanna look at the first couple but it shows OO vs functional approaches to the same problem in F#
Type extensions - add methods to types because you can

Mr Shiny Pants
Nov 12, 2012
F# is a beautiful language, I really like working with it. The community is also great: Fable, Paket, Fake etc. etc.

When I sit down to write F# code I feel happy, I like how it looks and how it works.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

Jewel posted:

That was pretty much my mindset, like, "I abused the hell out of Linq during the other years' AoC, why not just go full-throttle" but I'm worried full-functional is gonna be rough for every situation, which is why rust was the other option.

I mean it more literally than that. Not 'you have the potential to be', not 'you're close'. Nope, if you are comfortable/fluent with C# you're an F# dev also. There's nothing about F# that demands some sort of weird functional-burrito-purity, go ahead and write C# style code and use C# libraries - but you get at the bare minimum the advantage of a terser syntax and a stronger type system.

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Anyone know some particular algorithms or data structures I should use to efficiently find the intersection points of a series of 2D line segments?
The most basic implementation would be testing each pair of edges for (n^2) complexity, but I guess if I ordered them in some meaningful way, maybe it could be done in (n*log n) ? I just can't really picture a way to compare/sort them that makes sense.
Would a BSP or quad tree be ideal? I've never tried implementing one, just vaguely know of them.


Some more specifics of what I'm doing, in case there's even more specialized ways to do it:
This would basically be part of a 2D CAD "Offset" operation, where polygon edges are moved in or out along their normals depending whether the offset value is negative or positive. So the output after this offset could intersect in lots of ways which I need to clip to avoid self-intersecting contours, but I also need to make a sorted list of the exact intermediate offset values and the corresponding edges/vertices invloved, where each intersection happens.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
A simple ordering is by X coordinate of the leftmost endpoint. You can then take a given line segment, and process forward until it finds a segment whose left endpoint is right of the current segment's left endpoint; at that point they can't possibly intersect.

The more involved solution would be a quadtree for 2D, or octtree for 3D.

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

TooMuchAbstraction posted:

A simple ordering is by X coordinate of the leftmost endpoint. You can then take a given line segment, and process forward until it finds a segment whose left endpoint is right of the current segment's right endpoint; at that point they can't possibly intersect.
Ok, I think that would work, assuming you meant the correction I made in bold.

Otherwise, a trivial counterexample would be:

Black is current segment, red's left is to the right of black's left.

Also I might try a kd-tree, (which I had confused with BSP before), which AIUI is generally preferred over quadtrees? That is, if I decide to go beyond a simple single component sort suggested above.

peepsalot fucked around with this message at 03:04 on Dec 7, 2019

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Er, right. Whoops. :doh:

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

peepsalot posted:

Anyone know some particular algorithms or data structures I should use to efficiently find the intersection points of a series of 2D line segments?

This is a well studied problem. Here's one: https://en.wikipedia.org/wiki/Bentley%E2%80%93Ottmann_algorithm

Dawncloack
Nov 26, 2007
ECKS DEE!
Nap Ghost
This is in C. I am trying my hand at building a finite state machine for a class exercise.

We have to write a program that asks for a number of seconds and plays a noise. We are learning about GPIO in embedded systems.
Very simple thing, but I am happy that, for the first time, I sat down and sketched the whole flow graph and the whole thing and what's coming up is a result of that.

So: I defined an array of structs. Each member looks like this

code:

typedef struct SoundStateKeeper
    {
        unsigned int8_t *currentState; //All of the structs will have this pointer point at the State variable
        unsigned int32_t thisStateValue; //Initialized to zero, used in the first three states
        int32_t (*current_state_func)(* void); 
        void (*state_change)(int32_t); // Only this function can touch State

    }SoundStateKeeper;

// Later I set up everything
//Setup of the cleanup function, for example

        SoundStateKeeper[CLEANUP_AND_EXIT]->currentState = &State;
        SoundStateKeeper[CLEANUP_AND_EXIT]->thisStateValue = 0;
        SoundStateKeeper[CLEANUP_AND_EXIT]->current_state_func() = mem_liberator();
        SoundStateKeeper[CLEANUP_AND_EXIT]->state_change() = exit(int32_t);


The idea is that the program treats all the states the same way. There's going to be a while(1) and during each loop the current_state_func function and then the state_change function will run in that order. What will change is the variable state, so that, after initialization, what will be run is SoundStateKeeper[BASE_STATE]->current_state_func() (BASE_STATE is 0, but I use enums), then state_change will run, take the info inputted during the current_state_func(), pass it on to the next one, then change State. The loop starts again and runs the same two functions but State has changed, so the functions appropiate to that member of the struct array gets used.

So quick questions:

- Every member of the array has an identical pointer to the same int that signifies the current state.
code:
SoundStateKeeper[CLEANUP_AND_EXIT]->currentState = &State;
So in this case there's 5 members of an array of structs pointing to the same int. This is simply so everyone is clear on what the state is. It could even be a form of security, I could check for errors on any members with an if, so that "these member's function only get executed if the state is X or Y". My question is, is this kosher, is this something that might cause trouble?

- Should I use the restrict or register keywords on the members of the array ? I think restrict on function pointers doesn't work, but I am a beginner.

- Is it ok to try and bind an inbuilt function into a function pointer like so ?
code:
SoundStateKeeper[CLEANUP_AND_EXIT]->state_change() = exit(int32_t);
I bet it isn't, and obviously I can just create a proper and nice function that wraps around exit. But I am curious.

Thanks a lot in advance

Dawncloack fucked around with this message at 13:26 on Dec 8, 2019

nielsm
Jun 1, 2009



A small syntax detail: You only use parentheses after a function pointer member variable when you want to call the pointed-to function. When you want to act on the function pointer variable (i.e. change where the variable points to) you do not use parentheses.

C++ code:
// Set function pointer
SoundStateKeeper[CLEANUP_AND_EXIT]->current_state_func = &mem_liberator;

// Call through function pointer
int32_t state_function_result = SoundStateKeeper[CLEANUP_AND_EXIT]->current_state_func(whatever_parameter_the_function_takes);

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I wanted to go back to the topic of learning discrete math for programming and how it doesn't really correlate to day-to-day work. I did not see the correlation for years and it had more to do with my lovely math background than any real lack of a connection.

I got absolutely hosed transitioning from my Catholic elementary school to public middle school in math. We had not done any pre-algebra and I was screwed all the way through until my senior year of high school. Meanwhile, I was programming just fine and was writing a software audio synthesizer with an FFT for filtering. People would say programming is very mathematical and I would dismiss it because it didn't explain how I could do it.

When I got to college, I actually did fine with calculus and statistics since it was something like a reset. However, I was poo poo at discrete math and I still don't know why other than that I very rarely had to do anything with proofs before that and was paralyzed with whether I had achieved proper truth or something. Meanwhile, I was programming just fine.

I got a real complex about all this when I recently was building some stuff while also doing some 3d with Unity. I had been horrible at geometry and trigonometry before but I start getting all these spatial visualizations I never had before.

I have brought this up before in particular regards to algebra. To this day, if I have to solve for x in something taking more than five lines of scribbles then I. Will. gently caress. It. Up. I figured out it usually happens with a division, but that's about it. I can model things quite easily but the math afterwards is a trainwreck.

I think the problem with good programmers that are had at math is that the programming is coming from the part of the brain that does the math but the purely mathematical stuff is not. In the case of programming, there is a certain sense of logistics and temporality ("these things fit together in this order") that dominates the line-by-line stuff. I have some notion that a lot of abstraction in OOP intersects with set theory and discrete math ("this and that are related in this way but not that way therefore I can use this interface here to get what I need out of them").

So if I had to try again I would have more specific goals of trying to create those kind of mental models to solve the problems instead of trying to cram it into the part of my head that regurgitates things. I am pretty sure that was my problem growing up because the biggest thing I remember from pre-college math was cramming arithmetic tables because we had to do so many in 10 minutes in a drill or get detention. This was the obsession of our nun principal in elementary school. Hell, I would practice by sorting the exercises in a way that made it is faster to write down which was definitely more advanced math, but I didn't recognize it that way.

So IMO doing math stuff indeed is very valuable but you do need a goal unless you have mind that already puts math stuff in the right part of your head. I think that trying to code for some problems that could be better addressed with certain mathematical methods helps because it grounds these problems and grounds them particularly in the right part of your head where they will be useful later.

qsvui
Aug 23, 2003
some crazy thing

Dawncloack posted:

code:
typedef struct SoundStateKeeper
    {
        unsigned int8_t *currentState; //All of the structs will have this pointer point at the State variable
        unsigned int32_t thisStateValue; //Initialized to zero, used in the first three states
        int32_t (*current_state_func)(* void); 
        void (*state_change)(int32_t); // Only this function can touch State

    }SoundStateKeeper;

This doesn't compile. If you really mean unsigned int8_t, then just write uint8_t. Same goes for the int32_t. For current_state_func, if that isn't taking any arguments, leave out the * next to void.

Dawncloack posted:

- Should I use the restrict or register keywords on the members of the array ? I think restrict on function pointers doesn't work, but I am a beginner.
I wouldn't bother with register. Yes, restrict doesn't work with function pointers.

Dawncloack posted:

- Is it ok to try and bind an inbuilt function into a function pointer like so ?
code:
SoundStateKeeper[CLEANUP_AND_EXIT]->state_change() = exit(int32_t);
It is, but as written, this line doesn't compile. It's already been pointed out, but skip the parentheses on state_change and leave out the argument on exit.

Dawncloack
Nov 26, 2007
ECKS DEE!
Nap Ghost
Thanks for the notes guys! Sorry the code doesn't compile, it's all in the draft state.

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Are there linear time algorithms for checking whether or not a 2d polygon self-intersects? Cause I think I came up with one. I'm not 100% sure its correct yet, but seems like it would work so far. Trying to judge how big a deal that is if correct, and if I should try to publish a paper or something. I'm not in academia so idk anything about writing papers etc. Do fame and fortune await me?

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

peepsalot posted:

Are there linear time algorithms for checking whether or not a 2d polygon self-intersects? Cause I think I came up with one. I'm not 100% sure its correct yet, but seems like it would work so far. Trying to judge how big a deal that is if correct, and if I should try to publish a paper or something. I'm not in academia so idk anything about writing papers etc. Do fame and fortune await me?

Read my reply to your previous question.

More information here, including specifically the question of detecting if a polygon is simple (not self-intersecting): https://www.webcitation.org/6ahkPQIsN

Also it's (apparently) been shown that you can't do better than O(n log n) for line segment intersection. I'm not if that also applies to polygons but it seems likely. Edit or not, see below

HappyHippo fucked around with this message at 05:09 on Dec 10, 2019

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

peepsalot posted:

Are there linear time algorithms for checking whether or not a 2d polygon self-intersects? Cause I think I came up with one. I'm not 100% sure its correct yet, but seems like it would work so far. Trying to judge how big a deal that is if correct, and if I should try to publish a paper or something. I'm not in academia so idk anything about writing papers etc. Do fame and fortune await me?

There is a linear time algorithm for triangulating a polygon that can be used for detecting whether there is a self-intersection in linear time (https://www.cs.princeton.edu/~chazelle/pubs/polygon-triang.pdf) but no one uses it because frankly that is one dense loving paper and no one's got time to write code that does that especially given there are a bunch of easy (albeit slower) alternatives and computers are fast.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
https://arxiv.org/abs/0812.0893

A polygon is an example of a connected graph.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Bruegels Fuckbooks posted:

There is a linear time algorithm for triangulating a polygon that can be used for detecting whether there is a self-intersection in linear time (https://www.cs.princeton.edu/~chazelle/pubs/polygon-triang.pdf) but no one uses it because frankly that is one dense loving paper and no one's got time to write code that does that especially given there are a bunch of easy (albeit slower) alternatives and computers are fast.

It's a difficult paper to implement. It falls back in a few places on the old mathematicians trick of hand waving that something can be done because someone else showed you can do it on the dual of the thing they're talking about and good luck.

Edit:
Earlier in my career I spent 4 days trying to implement that paper and failed. Then I spent an hour and got ear clipping to work and gave no shits about the imperceptible cost differences in my ~1-2k vert polys.

leper khan fucked around with this message at 14:42 on Dec 10, 2019

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Thanks for the replies. I just read up a little on ear-clipping and realized that my idea was sort of a variant of that, with my own flawed definition of an "ear" which was not robust (and can't be easily fixed in linear time).

That said, the fast self-intersecting polygon check was just sort of a distraction from my original goal that I thought was interesting, but not something I directly needed to implement for my problem.

General_Failure
Apr 17, 2005
Can I get an opinion on something?
I've gone back to an old project of mine. Porting RISC OS to an unsupported SBC. I'm just pushing forward, doing it my way. I figured I'd tackle I2C to get back into things.
The OS supports low level bit banging and high level transfers. I opted to start with the bit banging version. The I2C hardware supports it like a not GPIO. Ie I can set input and output, read and write the lines.

I did the first build and test of ny port since February last night. My IIC code didn't work right. This didn't surprise me.
I'm after an opinion on this:

quote:

Sets the SDA and SCL lines on the specified bus. A 0 value represents logic LOW, 1 logic HIGH. The function then reads back and returns the values present on the bus, to permit arbitration.
from here:
https://www.riscosopen.org/wiki/documentation/show/HAL_IICSetLines

Is the read after writing done after setting SDA and SCL back to input to see what's on the bus? Or is it checking it while it's still an output?
If it is doing it while it's an output that's not a whole lot of time for anything to happen, but otherwise it makes more sense.

Linear Zoetrope
Nov 28, 2011

A hero must cook
So I'm getting interested in one of my old projects again: making a deckbuilder for Kingdom Hearts Re: Chain of Memories. God Goofy knows why I'd play this game again but I may do it in another playthrough of the series.

So basically, in COM there are sleights you can use to do special attacks, and building a sleight deck is essentially the only tolerable to play the game (in my opinion). Sleights operate on the following principle: you have an ordered (non-shuffled) deck chosen from a larger card list of yours. During combat if you choose an ordered set of 3 cards in the deck whose properties meet some constraint (usually related to something analogous to card "suit" or "color" and sum of the card "ranks"), you permanently remove the first card in the set from combat, temporarily discard cards 2 and 3 (which will be restored next time you go through your deck), and then execute an attack.

The "sleight deck": is basically abusing this mechanic so you can spam the sleight button and win. So for instance, Sonic Blade is a popular sleight for bosses, and to use it you need three cards whose "ranks" (0-9) sum to 20-23 (inclusive), and are all of different "suits" (there are 8 or 9 different attack card suits). So to build a Sonic Blade sleight deck you basically just get out a sheet of paper, write down your cards, and find some order that, for multiple reduction passes discarding the first of 3 cards, the next pass will still have cards that sum between 20-23, and all attack cards are still of different types/suits, for as many passes as possible.

There's also a deck limit, but instead of being number of cards, each card has its own cost and your deck has a cost limit.

A more complex folding sleight, which I only used for the final boss and is a pain to make, is a lethal frame deck. Lethal frame involves specifically the magic card "stop", followed by any two attack cards, rank/suit agnostic. So the trick there is to build the deck so that the first pass is all lethal frames, and then after that it reduces into a normal sleight deck (e.g. Sonic Blade above).

I'm wondering if anyone has any ideas for how to approach this. It seems like a cursed, even harder mashup of the subset sum and knapsack problems since we have 1. a cost limit, 2. the need for subsets to sum to a given range, 3. a hard size of the subset, 4. subsets-of-subsets to consider, 5. order matters, and 6. elements have additional constraints (tags like attack type, magic, etc). I'm leaving out some of the fuzzier constraints you can do when building by hand (e.g. "when we get to the last reduction it's acceptable for me to press left or right once or twice to get more mileage out of the reduction so they don't need to be strictly in order"), because it would just make it even harder. Can anyone think of any strategies for this? The additional constraints break almost every existing DP or approximate solution to subset sum and knapsack I can think of. I'm guessing it'd have to have some sort of heuristic-driven guess and check component because there's absolutely no way to solve it exactly, as well as just hardcoding certain things ("when building this sleight don't even bother to guess cards with value/type <X>"), but the multiple reduction step is the primary thing eluding me. I'm thinking the easiest way would be to build up the "last" reduction first, and then only insert things in the "discard" slots for the higher level, but then there's still the issue of backtracking in case there's a better option.

Linear Zoetrope fucked around with this message at 23:55 on Dec 11, 2019

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?

Linear Zoetrope posted:

So I'm getting interested in one of my old projects again: making a deckbuilder for Kingdom Hearts Re: Chain of Memories. God Goofy knows why I'd play this game again but I may do it in another playthrough of the series.

So basically, in COM there are sleights you can use to do special attacks, and building a sleight deck is essentially the only tolerable to play the game (in my opinion). Sleights operate on the following principle: you have an ordered (non-shuffled) deck chosen from a larger card list of yours. During combat if you choose an ordered set of 3 cards in the deck whose properties meet some constraint (usually related to something analogous to card "suit" or "color" and sum of the card "ranks"), you permanently remove the first card in the set from combat, temporarily discard cards 2 and 3 (which will be restored next time you go through your deck), and then execute an attack.

The "sleight deck": is basically abusing this mechanic so you can spam the sleight button and win. So for instance, Sonic Blade is a popular sleight for bosses, and to use it you need three cards whose "ranks" (0-9) sum to 20-23 (inclusive), and are all of different "suits" (there are 8 or 9 different attack card suits). So to build a Sonic Blade sleight deck you basically just get out a sheet of paper, write down your cards, and find some order that, for multiple reduction passes discarding the first of 3 cards, the next pass will still have cards that sum between 20-23, and all attack cards are still of different types/suits, for as many passes as possible.

There's also a deck limit, but instead of being number of cards, each card has its own cost and your deck has a cost limit.

A more complex folding sleight, which I only used for the final boss and is a pain to make, is a lethal frame deck. Lethal frame involves specifically the magic card "stop", followed by any two attack cards, rank/suit agnostic. So the trick there is to build the deck so that the first pass is all lethal frames, and then after that it reduces into a normal sleight deck (e.g. Sonic Blade above).

I'm wondering if anyone has any ideas for how to approach this. It seems like a cursed, even harder mashup of the subset sum and knapsack problems since we have 1. a cost limit, 2. the need for subsets to sum to a given range, 3. a hard size of the subset, 4. subsets-of-subsets to consider, 5. order matters, and 6. elements have additional constraints (tags like attack type, magic, etc). I'm leaving out some of the fuzzier constraints you can do when building by hand (e.g. "when we get to the last reduction it's acceptable for me to press left or right once or twice to get more mileage out of the reduction so they don't need to be strictly in order"), because it would just make it even harder. Can anyone think of any strategies for this? The additional constraints break almost every existing DP or approximate solution to subset sum and knapsack I can think of. I'm guessing it'd have to have some sort of heuristic-driven guess and check component because there's absolutely no way to solve it exactly, as well as just hardcoding certain things ("when building this sleight don't even bother to guess cards with value/type <X>"), but the multiple reduction step is the primary thing eluding me. I'm thinking the easiest way would be to build up the "last" reduction first, and then only insert things in the "discard" slots for the higher level, but then there's still the issue of backtracking in case there's a better option.

Have you considered getting obsessed with a different game

The most popular/successful set of techniques for highly constrained discrete programming problems like this are so-called ‘state-space relaxation’ methods. Unfortunately I don’t know these nearly well enough to teach them, and the iirc usual approach is ‘Find a professor who knows about state-space relaxation and agree a consulting fee’.

You might be able to get somewhere with a combination of brute force, heuristics and branch and bound. You didn’t say anything about how big is the card list from which you choose the deck, but if it’s (say) 400 cards, then the number of ordered 3 card combos is about 63 million, and presumably most of those aren’t feasible solutions, so you may be able to get a few steps in (e.g find all feasible 3, 4 card decks) via brute force.

After that I’d try tightening the constraints then progressively loosening them, so eg if you want to solve for decks with a maximum value of 100, do something like:

1) brute force solutions for 3,4 card decks, store them
2) set MaxValue = 1
3) Find candidate solutions by adding cards to the ‘tighter constraint’ solutions found in previous steps,
4) remove any candidate solutions that breach constraints
5) heuristically filter the set of solutions down filter if necessary (if it’s getting too large)
6) store all the solutions for this MaxValue
7) set MaxValue += 1 and repeat from (3)

This may or may not work, and there are a lot of details that it will be up to you to figure out, but it might give you a reasonable starting point.

General_Failure
Apr 17, 2005
This isn't a question. It's just a warning. I spent this morning writing a struct in a header which matches the structure of a workspace in assembly. I save regularly.
I just went back to it to add a final entry, and it was gone. There was a permissions issue. There was only a zero byte file.
I was using Code::Blocks. Apparently saves can fail silently.

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop
That's a bummer, I hope getting it back proves easier than expected and fear that you haven't done it quite the same way doesn't ruin your day. Notepad++ used to have a similar bug of sometimes silently writing a file of all zero bytes over an existing file.

General_Failure
Apr 17, 2005

Dumb Lowtax posted:

That's a bummer, I hope getting it back proves easier than expected and fear that you haven't done it quite the same way doesn't ruin your day. Notepad++ used to have a similar bug of sometimes silently writing a file of all zero bytes over an existing file.

It did cause me some irritation, but it's just a personal project and not for money so it's no big deal. Typing out huge headers of "#define"s or various data structure are some of my least favourite things, programming-wise. In the same project I have headers that took many, many hours of reading datasheets and implementing. So this one is only a minor loss.

Btw, I'm tempting fate by working on the current files on an NFS mount, because I want to use an IDE with things like autocomplete, and I can't use it on the same device which has the toolchain.
Okay, technically I can kind of sort of because some clever people made a linux hosted version of the same OS, but for some reason its performance has gone through the floor in the past ??? months, year? I don't know.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Have you considered working on files locally, and setting up the build config to sync everything up to the device before kicking off the toolchain?

JawnV6
Jul 4, 2004

So hot ...

General_Failure posted:

Can I get an opinion on something?

Is the read after writing done after setting SDA and SCL back to input to see what's on the bus? Or is it checking it while it's still an output?
If it is doing it while it's an output that's not a whole lot of time for anything to happen, but otherwise it makes more sense.

It's letting you check for a bus peripheral ACK. You'd write a '1', read back a '0' in the ACK case. You don't really 'drive' a 1 on I2C, you just let go and rely on the pull-up.

Are you setting the in/out state (is it 1 bit or two?) or are you just trying to understand what it's doing?

General_Failure
Apr 17, 2005

JawnV6 posted:

It's letting you check for a bus peripheral ACK. You'd write a '1', read back a '0' in the ACK case. You don't really 'drive' a 1 on I2C, you just let go and rely on the pull-up.

Are you setting the in/out state (is it 1 bit or two?) or are you just trying to understand what it's doing?

Trying to figure out how to do this without copypasting chunks of a datasheet.

On the device it has I2C hardware. It can do high level and line control mode. The operating system can also do both. From my perspective, low level is a good stepping stone.


We have:
SDA_CTL_EN and SCL_CTL_EN, which can allow control of SDA and SCL.
SDA_CTL and SCL_CTL, which set the line level.
SDA_STATE and SCL_STATE which read the current state of the pins.

What I'm trying to work out is if it would make more sense for the function to be reading the line state while the CTL_EN bits are enabled, to check whether it happened, or whether they should be disabled first and then read.
Also should I be leaving SCL_CTL_EN enabled maybe? Bear in mind I'm only interested in master mode at this point.

My last attempt at trying to get meaningful information out of the bus didn't quite work so I'll have to sprinkle some debugging feedback around. There really aren't many other choices in this circumstance.

hot cocoa on the couch
Dec 8, 2009

I'm trying to build a program for administering a betting game for myself and some friends. I wrote a little 500 word post up about it but I'm not sure where to post it. I'm basically looking for advice/resources on it's implementation. Should I post it here or go into project.log or...?

The Fool
Oct 16, 2003


:justpost:

Maybe updates once you get started should go in project.log, but feel free to ask for advice or questions or whatever.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I don't really know where to ask this...

Does anyone know if a simple thing exists to give a HTTP frontend to an arbitrary local executable?

I imagine something that takes a query string maybe, parses them for the command arguments, runs the command with arguments, and returns the command output.

I could write this easily enough, but it seems like something that'd just exist already.

nielsm
Jun 1, 2009



Thermopyle posted:

I don't really know where to ask this...

Does anyone know if a simple thing exists to give a HTTP frontend to an arbitrary local executable?

I imagine something that takes a query string maybe, parses them for the command arguments, runs the command with arguments, and returns the command output.

I could write this easily enough, but it seems like something that'd just exist already.

Classic CGI? Maybe with a light wrapper around the actual program.
https://httpd.apache.org/docs/2.4/howto/cgi.html

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Thermopyle posted:

I don't really know where to ask this...

Does anyone know if a simple thing exists to give a HTTP frontend to an arbitrary local executable?

I imagine something that takes a query string maybe, parses them for the command arguments, runs the command with arguments, and returns the command output.

I could write this easily enough, but it seems like something that'd just exist already.

It's been a while since we've seen a hand rolled arbitrary execution exploit being made

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Thermopyle posted:

I don't really know where to ask this...

Does anyone know if a simple thing exists to give a HTTP frontend to an arbitrary local executable?

I imagine something that takes a query string maybe, parses them for the command arguments, runs the command with arguments, and returns the command output.

I could write this easily enough, but it seems like something that'd just exist already.

Node.js

Adbot
ADBOT LOVES YOU

The Fool
Oct 16, 2003


Thermopyle posted:

I don't really know where to ask this...

Does anyone know if a simple thing exists to give a HTTP frontend to an arbitrary local executable?

I imagine something that takes a query string maybe, parses them for the command arguments, runs the command with arguments, and returns the command output.

I could write this easily enough, but it seems like something that'd just exist already.

I mean, maybe I’m not getting what you are trying to do but to me it seems like this could be solved by a bunch of things, from curl to electron.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply